Add Header to Category Pages
This topic contains 15 replies, has 4 voices, and was last updated by Moez Tharani 8 years, 5 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
October 23, 2016 at 9:21 pm #290292
I am using the 1280 Genesis child theme and modifying it to display a header on all pages. The code I’m using for this in the 1280 function.php is as follows. I’ve only extracted the code that determines whether or not to add the header. It’s separated out as such because I want on certain pages for it to grab the featured image, but on others (like geodirectory custom post types, I want a standard image). This works pretty much everywhere I want it to, except for geodirectory category pages and search pages (/places/category/ and /?geodir_search=1&stype=gd_place&sgd_placecategory%5B%5D=665&s=+&snear=&sgeodir_foodtypes%5B%5D=&sgeo_lat=&sgeo_lon=). Any thoughts on making it work for those two page types?
if ( is_page() || is_single() || is_category() || is_archive() || is_tag() || is_search() || ( is_home() && get_option('page_for_posts') ) ) { wp_enqueue_script( 'sk-backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/jquery.backstretch.min.js', array( 'jquery' ), '1.0.0' ); if ( is_singular( array( 'gd_place', 'gd_event', 'gd_pet_friendly', 'gd_adoptee' ) ) ) { wp_enqueue_script( 'sk-backstretch-set', get_bloginfo('stylesheet_directory').'/js/backstretch-set.js' , array( 'jquery', 'sk-backstretch' ), '1.0.0' ); wp_localize_script( 'sk-backstretch-set', 'BackStretchImg', array( 'src' => str_replace( 'http:', '', 'https://petpedia.ca/wp-content/uploads/2016/08/featured_dark.jpg' ) ) ); } else { wp_enqueue_script( 'sk-backstretch-set', get_bloginfo('stylesheet_directory').'/js/backstretch-set.js' , array( 'jquery', 'sk-backstretch' ), '1.0.0' ); wp_localize_script( 'sk-backstretch-set', 'BackStretchImg', array( 'src' => str_replace( 'http:', '', genesis_get_image( array('format' => 'url') ) ) ) ); } }
October 23, 2016 at 10:52 pm #290368By default, GD Listings and Search pages have the same header as any other page using the 1280 Genesis child theme. So I am not quite following…
October 24, 2016 at 6:54 am #290512Ok, I figured out a different approach to this, basically modifying the existing code instead of adding new code. In order to do what I need, I need to move the title from before the content sidebar to after the header. I changed:
add_action( 'genesis_before_content_sidebar_wrap', 'geo1280_page_title', 10 );
to
add_action( 'genesis_after_header', 'geo1280_page_title', 10 );
That has the desired effect on every page but the detailed listing page. On that page, the title is displayed twice. I don’t know enough about Genesis to understand why that’s happening. Any ideas? Link below shows the duplication.
https://petpedia.ca/dog_parks/alberta/calgary/off-leash/confluence-park-west-nose-creek/
October 24, 2016 at 9:38 am #290528I too am unsure of your desired outcome but this function might help you, you can identify GD pages with it: https://wpgeodirectory.com/codex/codex/geodirectory_functions/geodir_is_page/
Thanks,
Stiofan
October 24, 2016 at 2:22 pm #290689Well I’m past that now anyway. Now I just need to figure out why I get a duplicate header on the listing detail page. Any idea on that?
October 24, 2016 at 5:05 pm #290925Hi,
that’s because that theme already has an
with the title in it in the detail page. If you use the function Stiofan provided as condition, you can use the old snippet if the page is a detail page and your new snippet for all other pages.
Thanks
October 25, 2016 at 12:59 am #291290I’d actually prefer to replace the header in the detail page too. Is there a way for me to remove the header on the detail page as well?
October 25, 2016 at 4:06 pm #291563Hi,
for that you will need to tweak the function function
geo1280_page_title()
in functions.php
Thanks
October 26, 2016 at 2:39 am #291902Alright guys. I get that you’re probably busy and it’s easy to try and dismiss things under the guise of “custom, non-supported”, but I’m paying so that I don’t have to spend hours finding one line of code. And yet, that’s exactly what I’ve been forced to do. After literally hours of going through code trying to figure out what the hell is going on, I discovered this gem in the Genesis compatibility:
add_action('geodir_wrapper_open', 'geo1280_page_title', 101);
This makes it so that a duplicate title will appear when you do this:
add_action( 'genesis_after_header', 'geo1280_page_title', 10 );
So ultimately, this successfully repositions the title, without a duplicate appearing on the detail page:
remove_action('geodir_wrapper_open', 'geo1280_page_title', 10); add_action( 'genesis_after_header', 'geo1280_page_title', 10 );
October 26, 2016 at 2:55 am #291904So as it turns out, this doesn’t do anything in the geo-1280 function.php:
remove_action('geodir_wrapper_open', 'geo1280_page_title', 10);
The only way I can remove the duplicate title is by commenting out this in the compatibility file:
add_action('geodir_wrapper_open', 'geo1280_page_title', 101);
Obviously, that isn’t ideal. What’s the right way of doing this?
October 27, 2016 at 10:07 am #292712Hi again,
When removing an action you need the priority argument to be of the same value, in this case 101, so
remove_action('geodir_wrapper_open', 'geo1280_page_title', 101);
Thanks,
Stiofan
October 29, 2016 at 4:04 pm #294212I reverted the change to the compatibility file and inputted your suggestion to the child function.php. It didn’t work. So I’m back to modifying the compatibility file. Thoughts?
October 31, 2016 at 6:13 pm #295204Hi,
please provide a link and admin credentials so that we can add the function for you.
Thanks
November 1, 2016 at 12:23 am #295382This reply has been marked as private.November 2, 2016 at 5:16 pm #296856Hello,
I had posted on this earlier but the reply seems missing..
To remove the hook you must remove it after it was added: try this:
add_action('after_setup_theme', 'my_gd_compat_php_genesis_geo_1280_fix', 12); function my_gd_compat_php_genesis_geo_1280_fix(){ remove_action('geodir_wrapper_open', 'geo1280_page_title', 101); }
Thanks,
Stiofan
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket