dustyseb
Member
Posted 4 years ago #
Hi.
In the footer of every page I want to display the full content of a certain category.
I've tried:
<?php
global $post;
$myposts = get_posts('numberposts=4&category=3');
foreach($myposts as $post) :
?>
<ul>
<li><?php the_excerpt(); ?></li>
</ul>
<?php endforeach; ?>
but that just spits out the content from the main page.php
Help is greatly appreciated. Thanks.
thingymajig
Member
Posted 4 years ago #
Does this work for you?
<?php $posts = query_posts( 'showposts=4&cat=3' ); ?>
<?php if( $posts ) : ?>
<?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
<?php the_content('Read the rest of this entry »'); ?>
<?php endforeach; ?>
<?php endif; ?>
dustyseb
Member
Posted 4 years ago #
Hmm, that somehow breaks the entire page, empty?
http://dustybrush.net/onecall/onenumber-priser/
<?php the_content('Read the rest of this entry »'); ?>
I dont want any links, just display the posts of cat 3 in their entirety - if that's at all doable. I am setting up a cms for a client and I want them to be able to edit the footer content, which is divided into 4 parts horizontally (unordered list). Posts in the footer would be category "footer" (id 3).
Thanks for the super fast reply! :)
thingymajig
Member
Posted 4 years ago #
I know you didn't want any links in the cat 3 posts in the footer but I've got this code to work in my site now.
<?php $posts = query_posts( 'showposts=4&cat=3' ); ?>
<?php if( $posts ) : ?>
<?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
<div class="entry"> ***REPLACE THIS WITH YOUR OWN CLASS FOR ENTRIES***
<?php the_content('Read the rest of this entry »'); ?>
</div>
<?php endforeach; ?>
<?php endif; ?>
dustyseb
Member
Posted 4 years ago #
thanks again,
its still a bit strange. still breaks the site and leaves it empty
here's my footer.php:
<div class="kolo">
<?php $posts = query_posts( 'showposts=4&cat=3' ); ?>
<?php if( $posts ) : ?>
<?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
<div class="entry"> ***REPLACE THIS WITH YOUR OWN CLASS FOR ENTRIES***
<?php the_content('Read the rest of this entry »'); ?>
</div>
<?php endforeach; ?>
<?php endif; ?>
<div class="FooterWide">
<?php bloginfo('name'); ?> powered by <a href="http://wordpress.org/">WordPress</a> | <a href="<?php bloginfo('rss2_url'); ?>">Entries (RSS)</a> | <!-- <?php echo get_num_queries(); ?> queries. <?php timer_stop(1); ?> seconds. -->Denne side blev genereret på <?php timer_stop(1); ?> sekunder | Design Sebastian Larsen
</div>
</div>
</div>
<?php wp_footer(); ?>
</body>
</html>
I am stumped.
thingymajig
Member
Posted 4 years ago #
Well, here's mine for what it's worth...
<div id="footer">
<?php wp_footer(); ?>
<?php $posts = query_posts( 'showposts=4&cat=106' ); ?>
<?php if( $posts ) : ?>
<?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
<div class="entry">
<?php the_content('Read the rest of this entry »'); ?>
</div>
<?php endforeach; ?>
<?php endif; ?>
<div class="padding">
My own footer content is here
</div>
</div>
I'm using a edited version of the 'Sunrise' theme to test this instead of my usual theme. I will leave the test theme active for half an hour to give you chance to see it working.
thingymajig
Member
Posted 4 years ago #
dustyseb
Member
Posted 4 years ago #
ok thanks.
it does works for you. This is really bizarre.
I'll test on page.php a bit later to see if that makes a difference. Right now, I am having a slight fever, need to lie down for an hour :)
dustyseb
Member
Posted 4 years ago #
same thing in page.php.
the code breaks the entire site and leaves it blank. No source code, no nothing :-/
dustyseb
Member
Posted 4 years ago #
dustyseb
Member
Posted 4 years ago #
solved it, using Guff's get-a-post plugin.
http://guff.szub.net/2005/01/27/get-a-post/