Forums

Archive.php issue (14 posts)

  1. michaelmcguk
    Member
    Posted 1 year ago #

    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?

  2. Ivovic
    Member
    Posted 1 year ago #

    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 ;) )

  3. michaelmcguk
    Member
    Posted 1 year ago #

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

    Thank you

  4. Ivovic
    Member
    Posted 1 year ago #

    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.

  5. michaelmcguk
    Member
    Posted 1 year ago #

    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 :)

  6. Ivovic
    Member
    Posted 1 year ago #

    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.

  7. michaelmcguk
    Member
    Posted 1 year ago #

    Brilliante, worked a dream :D

    Thanks

  8. Ivovic
    Member
    Posted 1 year ago #

    anytime... :)

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

  9. michaelmcguk
    Member
    Posted 1 year ago #

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

    Thank you.

  10. michaelmcguk
    Member
    Posted 1 year ago #

    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?

  11. Ivovic
    Member
    Posted 1 year ago #

    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.

  12. michaelmcguk
    Member
    Posted 1 year ago #

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

    Thank you.

  13. Ivovic
    Member
    Posted 1 year ago #

    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.

  14. michaelmcguk
    Member
    Posted 1 year ago #

    hahaha tell me about it, try 200 in an hour :D

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.