Forums

Only show on home page (2 posts)

  1. ibblogosphere
    Member
    Posted 3 years ago #

    Hi everyone. I think this would be really easy for someone with php knowledge.

    I would like the following to only display on the homepage. I have attempted to wrap the... <?php if ( is_home() ) { ?> content <?php endif; ?> ...but it gives an error message in my sidebar.
    Here's the code and thanks in advance!

    <?php
    // this is where you enter the IDs of which categories you want to display
    $display_categories = array(11);
    foreach ($display_categories as $category) { ?>
    <div id="sidebar_header"> </div><div id="sidebar_gig">
    <?php query_posts("showposts=10&cat=$category");
    $wp_query->is_category = false;
    $wp_query->is_archive = false;
    $wp_query->is_home = true;
    ?>

    <h3>"><?php
    // this is where the name of each category gets printed
    single_cat_title(); ?>
    </h3><div class="sub_text">This week's gigs ¬</div>
    <?php while (have_posts()) : the_post(); ?>

    " rel="bookmark" class="title">


    <?php the_excerpt(); ?>
    " rel="bookmark" title="Permanent Link to <?php the_title(); ?>">More»
    <?php endwhile; ?>

    </div>
    <div id="sidebar_footer">
    <div class="icons"><!-- AddThis Button BEGIN -->
    <?php echo "<div>
    <script type=\"text/javascript\">
    var addthis_pub=\"strutter27\";
    var addthis_logo = 'http://www.boxadesign.co.uk/thejoycollective/wp-content/themes/mimbo2.2/images/joy_logo.gif';
    var addthis_brand = 'The Joy Collective';
    </script>
    <img src=\"http://s7.addthis.com/static/btn/sm-plus.gif\" width=\"16\" height=\"16\" alt=\"Bookmark and Share\" style=\"border:0\"/><script type=\"text/javascript\" src=\"http://s7.addthis.com/js/200/addthis_widget.js\"></script></div>"; ?>
    <!-- AddThis Button END --></div>
    <div class="footnote">">view all gigs</div>
    </div>

    <?php } ?>

  2. MichaelH
    Volunteer
    Posted 3 years ago #

    So you want to display 10 posts from category id=11 in your sidebar, but only when viewing the home page?

    Also are you using the Static Front Page option in Settings->Reading?

Topic Closed

This topic has been closed to new replies.

About this Topic