• Hello,

    Any help with this would be brilliant.

    My current ‘News page’ is like: /index.php?cat=5 however, on this page(which is styled by archive.php), I also want a bit underneath it to show all the posts that should be in /index.php?cat=12 , is this a possibility.

    Can someone show me how?

Viewing 13 replies - 1 through 13 (of 13 total)
  • seriously dude, get out of my time zone…

    <?php
    if (is_category(5)) :
        $readposts = get_posts('numberposts=5&category=12');
        foreach($readposts as $post) : setup_postdata($post);
        ?>
    
           [regular post stuff goes here]
    
        <?php
        endforeach;
    endif;
    ?>

    This should work, barring any tyops.

    (I was kidding about the time zone thing… mostly ?? )

    Thread Starter michaelmcguk

    (@michaelmcguk)

    Hahahah, don’t worry, that is the last question. I’m going to become an Insomniac to keep out the time zone thang ??

    Thank you

    haha, you’re welcome… don’t worry, I’m kidding, I wouldn’t be here if I didn’t get some perverse joy out of other people’s suffering.

    I mean… I like helping people.

    Thread Starter michaelmcguk

    (@michaelmcguk)

    Haha, can’t help but get a kick out of the old suffering game ??

    I seem to be getting a Parse Error on the ‘endforeach’ part:

    Parse error: syntax error, unexpected T_ENDFOREACH

    My code:

    <?php
    		if (is_category(5)) :
        			$readposts = get_posts('numberposts=5&category=12');
        			foreach($readposts as $post) : setup_postdata($post);
        		?>
           			<?php while (have_posts()) : the_post(); ?>
    		<div class="post">
    				<h3 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h3>
    				<small><?php the_time('l, F jS, Y') ?></small>
    
    				<div class="entry2" style="margin-right:135px;position:relative;">
    
    				<?php the_content() ?>
    				</div>
    
    		</div> <!-- end of post class element -->
    
        		<?php
        		endforeach;
    		endif;
    		?>

    Promise this is the last time I ask ??

    ah, its because you’re putting the while loop and stuff in there as well…

    I mean lets get that right first, then we’ll know for sure.

    put only this part into my code above:

    <div class="post">
       <h3 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h3>
       <small><?php the_time('l, F jS, Y') ?></small>
       <div class="entry2" style="margin-right:135px;position:relative;">
          <?php the_content() ?>
       </div>
    </div>

    I’ve left out the parts you have got commented there, since they wouldn’t be showing up anyway.

    Thread Starter michaelmcguk

    (@michaelmcguk)

    Brilliante, worked a dream ??

    Thanks

    anytime… ??

    remember to vary the numposts= part, or remove it if you want them all.

    Thread Starter michaelmcguk

    (@michaelmcguk)

    Aaaah good call. I’ll probably want to list them all, so may remove that clause.

    Thank you.

    Thread Starter michaelmcguk

    (@michaelmcguk)

    Is there an is_not_category?

    I’ve been trying things like:

    if (!in_category(’26’) && !in_category(‘3’) )

    if (!is_category(’26’) && !is_category(‘3’) )

    but getting nowhere ??

    Have you experienced this before?

    the !is_category should work.. but.. your conditional is kind of odd because no one thing can be both category 26 AND category 3 at the same time.

    maybe you want || which is a logical OR…

    that way either 26 or 3 are covered.

    this assumes you’re actually doing this on a category page as per this thread, and not in a single post or something.

    Thread Starter michaelmcguk

    (@michaelmcguk)

    Yes, sorry it should be the || I’m using.

    Thank you.

    I get those screwed up all the time. If you could see my FTP logs you’d find the same file uploaded 16 times in the same 5 minutes, as I discover yet more brain farts.

    Thread Starter michaelmcguk

    (@michaelmcguk)

    hahaha tell me about it, try 200 in an hour ??

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Archive.php issue’ is closed to new replies.