Forums

[resolved] How to remove meta by category? (6 posts)

  1. rwilki
    Member
    Posted 3 months ago #

    I've read a lot of information about this but haven't found an answer. For one particular category, I need to hide the author meta information. Is there a conditional statement that can help with this?

    Thanks,
    Bob

  2. deepbevel
    Member
    Posted 3 months ago #

    You should be able to wrap the meta code with:

    <?php if (is_category('category-slug')) { ?>
    
    (Your Meta Code Here)
    
    <?php } ?>
  3. rwilki
    Member
    Posted 3 months ago #

    Thanks deepbevel the code makes sense but didn't work. It was hiding everything.
    I'm wondering if I should use category IDs instead?

    So if I have a category 'dogs','cats', and 'other' do you have any ideas?

    Thanks,
    Bob

  4. deepbevel
    Member
    Posted 3 months ago #

    Is this for single.php or an archive/category template?

    try using "in" category instead of "is".

  5. rwilki
    Member
    Posted 3 months ago #

    thanks for your reply. it's a single.php template. i actually figured out another way. I added this code at the top of my single.php file

    <?php
    if(in_category(xx)) {
    // Custom Template for Single Posts in Category xx
    include 'template-xx.php';
    } else {
    ?>

    Then I created a duplicate single.php template without the extra php code and called it template-xx.php, added reference for a custom header that used a custom style sheet, and set the meta code to display:none.

    It was more work than I wanted to do, but I couldn't figure out another way.

    thanks again for your help.

  6. deepbevel
    Member
    Posted 3 months ago #

    Good solution.
    That's why the conditional didn't work. "Is category" is for archives.
    It's probably just as well, in case you want to do more customizing later. Too many conditionals gets confusing fast.

Reply

You must log in to post.

About this Topic