WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Only Show If There Is Posts (6 posts)

  1. marcoapaulo
    Member
    Posted 1 year ago #

    Hi everyone,

    What I'm trying to do it's very simple, or I think it is, but my problem is "how to do it?".

    So, I've searched through the forum and got no solution, or at least, I couldn't use it.

    What I'm trying to do is: if there's posts in a category, a specific block appears with the content, if there's no posts at all in that category, that block doesn't appear on the site.

    I know it has something to do with "if" and "else", but I can't get the code to work...

    In here http://pastebin.com/xfu5jghW you can find the code I want to hide if there is no posts in the category "Destaque". If there is, then I want it to show on the site.

    Thank you in advanc

  2. bythegram
    Member
    Posted 1 year ago #

  3. marcoapaulo
    Member
    Posted 1 year ago #

    Got an error on the second line.

  4. bythegram
    Member
    Posted 1 year ago #

    opps change it to <?php if ( have_posts() ) : ?> sorry

    http://pastebin.com/txv3W6Cu

  5. marcoapaulo
    Member
    Posted 1 year ago #

    Ah it worked :) Thank you!

  6. bythegram
    Member
    Posted 1 year ago #

    cheers!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags