The Loop inside a function: some thing works, other don’t
-
I want to put The Loop inside a function to show the most recent post of some categories in different places of my home page. I’ve written the following function, but although THE_CONTENT works, THE_TITLE shows the same title for both posts. Help, please!
<?php
function show_posts($id_categoria) {
$posts=get_posts(“category=$id_categoria&numberposts=1”);
if ($posts) :
foreach($posts as $post) :
setup_postdata($post); ?>
<h2>“><?php the_title() ?></h2>
<?php the_content(“[Més…]”); ?>
</div>
<?php
endforeach;
endif;
}
?>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘The Loop inside a function: some thing works, other don’t’ is closed to new replies.