Change text before entry-categories for specific categories on genesis framwork wordpress

Im trying to change “Filed Under:” for all our service categories and pages (Doors, Flooring, Painting and Windows) the IDs for each categories are as follows 4,5,6,7 and the IDs for each service page is as follows 28,30,32,34.

I got this code from the Studiopress website but it changes all the text before entry-categories globally. I tried to modify it below but its not working.

Read More
//* Customize the post meta function
add_filter( 'genesis_post_meta', 'sp_post_meta_filter' );
function sp_post_meta_filter($post_meta) {
    if ( !is_page() ) {
        $post_meta = '[post_categories before="Filed Under: "] [post_tags before="Tagged: "]';
        return $post_meta;
    }
}

I have 4 pages (the service pages IDs are above) which are all utilizing a blog template and pulling query_args with cat=ID for each category to showcase the jobs in that category.

I also have a portfolio page (ID=13) to showcase all the jobs associated with the categories above.

Then there is a blog page for company updates and news and will not showcase any jobs (Blog page ID=19). I still want posts on this page to display “Filed Under:”.

On the portfolio and service pages I want to change “Filed Under:” to “Service:”. I want this change to remain in effect on the actual post of the job as well and on the category page (Im not utilizing the category page but if someone clicks on the service type it will take them there).

I hope this is more clear…

Here is the code I have been playing with and attempting but its still not working. I’m not sure if I’m using the is_page correctly of if i need to be using something else.

//* Customize the post meta function
add_filter( 'genesis_post_meta', 'sp_post_meta_filter' );
function sp_post_meta_filter($post_meta) {
    if ( !is_page( array(13,28,30,32,34)) ) {
        if ( !is_category( array(4,5,6,7) ) ) {
            $post_meta = '[post_categories before="Service: "] [post_tags before="Tagged: "]';
        } else { 
            $post_meta = '[post_categories before="Filed Under: "] [post_tags before="Tagged: "]';
        } 
        return $post_meta;  
    }
}

Related posts

2 comments

  1. This will change the following to say ‘Service’:

    • Any page that is in categories 4,5,6,7
    • Any category page that is 4,5,6,7
    • The portfolio page (ID=13)

    Everything else will say ‘Filed Under’

    add_filter( 'genesis_post_meta', 'sp_post_meta_filter' );
    function sp_post_meta_filter($post_meta) {
        if((is_page() && in_category(array(4,5,6,7))) || (!is_page() && is_category(array(4,5,6,7))) || (is_page() && get_the_ID() == 13)) {
            $post_meta = '[post_categories before="Service: "] [post_tags before="Tagged: "]';
        }
        else
        {
            $post_meta = '[post_categories before="Filed Under: "] [post_tags before="Tagged: "]';
        }
        return $post_meta;  
    }
    
  2. Thank you Mongjong for putting me on the right path and getting me so far. I was able to tweak your solution a little further to accomplish all my needs! Here is my final code that is working perfectly! 🙂

    //* Customize the post meta function
    add_filter( 'genesis_post_meta', 'sp_post_meta_filter' );
    function sp_post_meta_filter($post_meta) {
        if((is_page() && in_category(array(4,5,6,7))) || (!is_page() && is_category(array(4,5,6,7))) || (is_single() && in_category(array(4,5,6,7))) || (!is_single() && in_category(array(4,5,6,7))) || (is_page() && get_the_ID() == 13)) {
            $post_meta = '[post_categories before="Service: "] [post_tags before="Tagged: "]';
        }
        else
        {
            $post_meta = '[post_categories before="Filed Under: "] [post_tags before="Tagged: "]';
        }
        return $post_meta;  
    }
    

Comments are closed.