vijendramisra
Member
Posted 2 years ago #
I want to display small intro matter before all posts on home page and it will come only on home page and no where else. How to do that? I tried to do it by showing post by specific ID but and exclude that post from normal loop but now this post is visible on all pages... please help. Thanks
have you tried creating a home.php?
The hierarchy.
Peter
aianta03
Member
Posted 2 years ago #
Look for a Sticky posts plugin. Than make that intro post sticky see if it works.
gwozdz.mateusz
Member
Posted 2 years ago #
<?php query_posts('category_name=Your_Categ_Name&showposts=1'); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="sidebar_cont"><?php the_content(__('Czytaj Całość...')); ?></div>
<?php endwhile;?>
This will display post from any category U want, by its name. The problem is that when U have posts being displayed like this in for example sidebar, than when U go to single posts's page it won't display only intro but whole post.
Anybody knows how to solve this please write!
Thanks a lot
And hope this was helpful
Cheers
gwozdz.mateusz
Member
Posted 2 years ago #
Ok, problem solved. What U need to add is
global $more;
$more = 0;
So, query_posts, will look like this:
<?php query_posts('category_name=Your_Categ_Name&showposts=1');
global $more;
$more = 0;
?>
And than the part for displaying the post
<?php while (have_posts()) : the_post(); ?>
<div class="sidebar_cont"><?php the_content(__('Czytaj Całość...')); ?></div>
<?php endwhile;?>
Ok, hope it is what U needed
Cya
p.s. U may want to read this: http://codex.wordpress.org/Template_Tags/query_posts
very useful