How to hide/show pages block in the side bar? (3 posts)

  1. james12
    Posted 10 years ago #


    I'm designing a new theme for word press 1.5. With this new theme every category (blogroll, pages, etc) in the sidebar is shown in a separate block. The problem is that if there's no pages in the pages category the block 'pages' is still shown on the sidebar and it looks not very good. I would like to fix it so if there're some pages they are shown (with the block) and if there's no pages the block is not shown. Can anybody help me with it?

  2. Beel
    Posted 10 years ago #

    What code are you using to display the block currently?

  3. Ment0r
    Posted 10 years ago #

    here some small hack. i dont know if its to suggest, but it works. maybe someone else has another idea.

    try this within your templates:

    <?php $pages = $wpdb->get_results("SELECT count(*) as numpages FROM $wpdb->posts WHERE post_status = 'static'", ARRAY_A);
    if($pages[0][numpages] >= 1) { ?>

    ... we have pages

    <?php } else { ?>

    ... we don't have pages

    <?php } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.