I need code that will grab 2 specific categories from my loop and post in on a static page or a page template. I have looked through all the documentation on wordpress involving loops and get_posts as well as query_posts and in there forum and other help sites but I can't get anything working for me. Has anyone done this before?
I need a home page that shows two categories.
Featured artist and Gigs
there will be a separate page called Blog which is where the normal loop with all the categories will be.
cheers,
-ag
get_posts from loop in Wordpress
Moderator: General Moderators
Re: get_posts from loop in Wordpress
This is actually something that works very well when I put it in the static page as content, it would show 1 category and 5 permalinks. But I think it's meant to function with the blog loop not on a static page and I can't get it to show 2 categories. There must be a better way.
Code: Select all
<ul>
<?php
global $post;
$args = array( 'numberposts' => 5, 'offset'=> 1, 'category' => 1 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>