Education theme – hide tags and categories from visitors

Community Forums Forums Design Tips and Tricks Education theme – hide tags and categories from visitors

This topic is: resolved

This topic contains 5 replies, has 2 voices, and was last updated by  studiopress@tibesar.com 1 year, 6 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #12527

    studiopress@tibesar.com
    Participant
    Post count: 17

    I want to hide all tags and categories in my Posts and Excerpts from site visitors:

    If logged in:  display tags and categories
    If logged out :  do NOT display tags and categories in the Posts and Excerpts

    I tried this code in the functions.php but it did not work:

    if ( is_user_logged_in() ) {
    $post_meta = ‘[post_categories] // [post_tags]‘;
    } else {
    $post_meta = ‘logged out’;
    }
    return $post_meta;

    I am not a php developer so I would appreciate any comments or suggestions. Thank you so much!

    Theme: Education
    Site: tibesar.com

    #12662

    cdils
    Participant
    Post count: 420

    Hi there,

    You’ll need to use the genesis_post_meta filter. Try something like this in your functions.php. You’ll notice it’s basically your same code above, but it needs to be wrapped in a function and read in via a filter.

    /** Customize the post meta function */
    add_filter( 'genesis_post_meta', 'post_meta_filter' );
    function post_meta_filter($post_meta) {
    if ( is_user_logged_in() ) {
        $post_meta = '[post_categories] // [post_tags]';
        return $post_meta;
    }}


    Carrie


    Have you been helped in this forum? Pay it forward and answer someone else’s question. I bet you’ll know the answer to at least one question. :)

    I tweet @cdils.

    #12708

    studiopress@tibesar.com
    Participant
    Post count: 17
    This reply has been marked as private.
    #12711

    cdils
    Participant
    Post count: 420

    Once you throw an error in functions.php, it’s impossible to edit any further in the WP dashboard. You’ll need to access the file via FTP and remove the code that way. That should reset you.

    Before adding in this code, make sure you remove your previous code so it doesn’t throw another error. :)

    Not directly related, but still helpful… You might like this article (http://surefirewebservices.com/wordpress/how-to-use-remove_action-with-conditional-tags). It explains the why of using functions.


    Have you been helped in this forum? Pay it forward and answer someone else’s question. I bet you’ll know the answer to at least one question. :)

    I tweet @cdils.

    #12713

    studiopress@tibesar.com
    Participant
    Post count: 17
    This reply has been marked as private.
    #12778

    studiopress@tibesar.com
    Participant
    Post count: 17

    Good evening Carrie,

    The code you provided works great.

    This code should be added to the Genesis snippets library.

    Hiding tags is a significant security enhancement to private Genesis websites.

    Accordingly, you have enhanced the security of our archives and, we appreciate your contribution and sharing.

    Cheers!

    Marcus Tibesar

    The Tibesar Archives

    http://tibesar.com

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Education theme – hide tags and categories from visitors’ is closed to new replies.