Edit post_info in functions.php not working

Community Forums Forums Design Tips and Tricks Edit post_info in functions.php not working

This topic is: not resolved

This topic contains 6 replies, has 3 voices, and was last updated by  njb 10 months, 4 weeks ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #60276

    njb
    Participant
    Post count: 3

    I have tried and tried to figure out what I’m doing wrong. I’ve added the following to the bottom of my child-theme’s functions.php:

    //* Customize the post info function by category
    add_filter( 'genesis_post_info', 'post_info_filter' );
    function post_info_filter($post_info) {
    if ( !is_category( 'our-team' ) ) {
    	$post_info = '[post_edit]';
    	return $post_info;
    }}

    My hope is to modify both the post pages and the category archive so only [post_edit] is displayed for the category ‘our-team’. I’ve tried several variations with no luck (an no changes) to the category archive found at: http://www.faith3.org/category/our-team/

    http://www.faith3.org/category/our-team/
    #60354

    Sridhar Katakam
    Participant
    Post count: 923

    This should work:

    //* Customize the post info function
    add_filter( 'genesis_post_info', 'sp_post_info_filter' );
    function sp_post_info_filter($post_info) {
    	if ( in_category('our-team') ) :
    		$post_info = '[post_edit]';
    	else :
    		$post_info = '[post_date] by [post_author_posts_link] [post_comments] [post_edit]';
    	endif;
    	return $post_info;
    }

    #60357

    braddalton
    Participant
    Post count: 8871

    This code works because i tested it.

    Grab the category i.d by hovering over the edit category button once logged in.

    Note: You must deactivate the Genesis Simple Edits plugin otherwise PHP code will not work if it includes the genesis_post_info filter hook.

    https://gist.github.com/braddalton/6419983


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #60358

    Sridhar Katakam
    Participant
    Post count: 923

    Thanks Brad.

    As you are probably already aware, providing the category slug will work as well and makes it readable. I too tested the code before adding my reply :)


    #60361

    braddalton
    Participant
    Post count: 8871

    Please be aware that the code you provided will not work if the Genesis Simple Edits plugin is activated.

    Based on my experience, the i.d is the preferred method when using conditional tags. Not the page slug as it doesn’t always seem to work.

    Just trying to help @njb resolve a problem.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #60363

    Sridhar Katakam
    Participant
    Post count: 923

    Oh IC.

    I have not yet started using Genesis Simple Edits plugin. Good to know.

    Thank you.


    #60388

    njb
    Participant
    Post count: 3

    Note: You must deactivate the Genesis Simple Edits plugin otherwise PHP code will not work if it includes the genesis_post_info filter hook.

    @braddalton Thank you! This was exactly what I was missing. Solved!

    • This reply was modified 10 months, 4 weeks ago by  njb.
    • This reply was modified 10 months, 4 weeks ago by  njb.
Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.