• Hey all I know when there are no posts and categories selected the page will display nothing and possibly a message if you have set one up to let visitors know there is no current content at the time.

    But I wanted to know if you create say a template.php page to give your page a certain look… for instance I’m setting up a blog page where after each displayed post there is a 1px dotted bottom border – black as well I have a text link for those who want to share the post to Facebook. The border is applied in my css file and the link is hard coded into the template I’ve created for the blog page, but if I don’t post anything then the border and content is invisible but the link is still there as well I also have a topsy_retweet button there due to placing this code <?phpif(function_exists('topsy_retweet_small')) echo topsy_retweet_small(); ?> in my template after the loop statement.

    My question is is there a code statement that I can place in my template that would tell WP if I don’t have a category selected or post for it to not display anything including the static elements on the page? Sorry I don’t have a site link up as of yet for this to visually show and example but I hope it makes sense in theory…
    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Try placing your static content after <?php if (have_posts()) :?>

    Thread Starter junkhed1

    (@junkhed1)

    Thanks esmi completely overlook that statement.
    I appreciate your assistance!

    Thread Starter junkhed1

    (@junkhed1)

    Hey esmi if I could ask another question would you know if I’m using this coding here `
    <?php $recent = new WP_Query(); ?>
    <?php $recent->query(‘cat=12&showposts=1’); ?>
    <?php if($recent->have_posts()) : $recent->the_post(); ?>

    <h2>“><?php the_title(); ?></h2>
    <p class=”meta”>posted by <?php the_author(); ?> on <?php the_time(‘F j, Y’); ?> at <?php the_time(‘g:i a’); ?></p>
    <?php global $more; $more = 0; ?>
    <p><?php the_content(‘read more’); ?></p>

    <div class=”BlogComments”>
    “><?php comments_number(‘0’, ‘1’, ‘%’); ?> Comment(s)
    </div><!–end blogcomments–>

    <div id=”retweet”>
    <?php if (function_exists(‘topsy_retweet_small’)) echo topsy_retweet_small(); ?>
    </div><!–end retweetTW –>
    <div id=”shareFB”>
    &t=<?php the_title(); ?>” target=”blank”>Share on Facebook
    </div><!–end shareFB div–>
    <?php endif; ?>

    <div id=”blog_message”>
    <p>Please check back shortly for updated blog content!</p>

    </div>

    </div><!–end blog post–>
    </div>`

    the div – blog_message: displays the message on the page and the content is gone after using your suggestion of <?php if (have_posts()) :?> but if I place content in the message is still there under the post would you know what conditional statement I would use to make the message disappear when content is present?

    Thanks again.

    Try:

    <div id="blog_message">
    <p>Please check back shortly for updated blog content!</p>
    <?php endif; ?>
    </div>
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Not showing static elements in Categories’ is closed to new replies.