• Hi All,

    So after reading lots of posts checking “the loop” docs I couldn’t find what I want :

    So i want to include a “file.php” in my Home page which display ONLY One category like as “https://lesartisans.org/” (my Beta) but my main problem is that when i change page by clicking in a post (eg.https://lesartisans.org/2006/11/30/test-du-linksys-wip330-un-telephone-multiplateformes-wi-fi/) is displaying
    not anymore the same results !

    How to keep this middle column that contaimn my category style the same ???

    Thanks !

    PS : Here is the code of the “middle-col.php” page :

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    <!– If the post is in the category we want to exclude, we simply pass to the next post. –>
    <?php if (in_category(‘1’) || in_category(‘2’) || in_category(‘3’) || in_category(‘4’) || in_category(‘8’) || in_category(‘9′) || in_category(’10’) || in_category(’11’) || in_category(’12’) || in_category(’13’) || in_category(’14’) || in_category(’15’) || in_category(’16’)) continue; ?>

    <div class=”post”>

    <h2>“><?php the_title(); ?></h2>

    <h3><img src=”<?php bloginfo(‘stylesheet_directory’); ?>/images/timeicon.gif” alt=”” /> <?php the_time(‘jS F Y’) ?> by <img src=”<?php bloginfo(‘stylesheet_directory’); ?>/images/author.gif” alt=”” /> <?php the_author() ?> </h3>

    <div class=”entry”>
    <?php the_content(); ?>
    </div>

    <p class=”postmetadata”>Posted in <?php the_category(‘, ‘); ?></p>
    </div> <!– closes the first div box –>

    <?php endwhile; else: ?>
    <p>Sorry, no posts matched your criteria.</p>
    <?php endif; ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • <?php if (in_category('1') || in_category('2') || in_category('3') || in_category('4') || in_category('8') || in_category('9') || in_category('10') || in_category('11') || in_category('12') || in_category('13') || in_category('14') || in_category('15') || in_category('16')) continue; ?>

    Wow. So, why not use in_category() to test for the *one* category you want to display, rather than using this complicated string to exclude all the other categories?

    Anyway…

    The problem with your disappearing column is, on a single post page there’s only a single post in the default posts loop. That’s unavoidable. So to collect those posts appearing on your home page, insert this above the middle column’s post loop:

    <?php $midposts = new WP_Query('showposts=10'); ?>

    (Edit the showposts value to suit your needs.)

    Then modify the start of the middle column’s posts loop like so:

    <?php if ( $midposts->have_posts() ) : while ( $midposts->have_posts() ) : $midposts->the_post(); ?>

    Thread Starter wifiman01

    (@wifiman01)

    Kafkaesqui,

    Yes it could be used more user friendly for cats but i’m not so much good in coding !

    Anyway…

    Your small code functions works very well it seems. I will see when I will insert all our oldposts how is going on but i have no doubt that work like we want.

    Thank you very much in our name and name of our future visitors who are visiting our actual site https://www.planet-wifi.com.

    PS : Could you send me a private mail ?

    Thread Starter wifiman01

    (@wifiman01)

    Kafkaesqui,

    I discover another boring thing : When i’m using all that code is working fine but the problem is when the post located in the “test” category that show my middle col is not anymore in the main page it drops too in the middle col !

    How can i fix that it stay visible on my middle column event is not anymore in the main page (left column) ?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Include One category code !’ is closed to new replies.