Get a list of posts on a static page
-
Hi there,
I’m trying to get a list of posts of a certain category on a page. On that page is a shortcode like [get_list].
The markup should look like this:<ul> <li> <a href="#"id="">'.the_title().'</a> <a href="#"id="">'.the_title().'</a> ... </li> </ul>
I tried this:
function get_offenestellen( $atts ) { if (is_page()) { $cat=12; $posts = get_posts ("cat=$cat&showposts=5"); if ($posts) { foreach ($posts as $post): setup_postdata($post); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <?php endforeach; } } return; } add_shortcode( 'offene_stellen', 'get_offenestellen' );
But all I get is like links to the page I’m currently on (the one with the shortcode on).
What’s my mistake? Can you help me?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Get a list of posts on a static page’ is closed to new replies.