elegant themes

Display posts from specific categories on a Page

| November 8, 2007 | 97 Comments

You may want to display posts from a specific category on the homepage or other pages of your site. For example, you might want to have a box that displays the latest three posts from your News category, or have links to your latest podcasts.

In a previous post, I gave the code that would display the latest posts from a specific category in the sidebar. However, that code will not work in the main content part of the page. In order to display posts from a specific category in the main content section of a page, you need to use a variation on the WordPress Loop, which is as follows:
<?php query_posts('category_name=special_cat&showposts=10'); ?>
<?php while (have_posts()) : the_post(); ?>
<!-- Do special_cat stuff... -->
<?php endwhile;?>


To use this code, change the category name to whatever the name is of the relevant category, and change the number of posts displayed from 10 to whatever number you want. Where it says <!-- Do special_cat stuff... -->, put in all the code you usually use to display the title, date, category, etc. – whatever you need.

0saves
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Tags:

Category: Code Snippets, WordPress as CMS

solostream

Comments (97)

Trackback URL | Comments RSS Feed

  1. mccormicky says:

    I’m a little confused.You don’t mention in this article making a separate template file to insert this modified loop into so I am assuming that I’d add this TO the loop?
    Or if I DID use my own template file which is basically just my page.php file copied could this code work Exactly as you have written it?
    Does categry_name refer to the category slug?Or do I use the id?
    I’ve messed around with this but so far all I get is a blank page with my title showing.

  2. Miriam says:

    mccormicky – you have to use this instead of the loop in the page where you want to display posts in a specific category. You probably don’t want to do this on every page of your blog, so you have to figure out where you want the blog posts from one category to appear, and then you replace the loop on that page.

    For example, if you have a unique design for your Home page, and you’ve created a page template called home.php, you replace your loop in that template file with the code above.

    The easiest way to do it is simply to replace the first line of the regular loop, which is something like < ?php if (have_posts()) : ?>, and replace it with < ?php query_posts('category_name=special_cat&showposts=10');?>
    Where it says “special_cat”, you replace that with the NAME of your category, which is the slug.

  3. [...] – this plugin enables you to exclude posts from certain categories from your front page. This is possible by hard coding your template files as well, but for those who want to give others the ability to do this easily, or who just [...]

  4. mgmt says:

    I think if you replace this line of code <?php query_posts(‘category_name=special_cat&showposts=10′); ?>
    with this line <?php query_posts(‘cat=2&showposts=10′); ?> it will be easer to understand
    all you have to add to this is that 2 is the ID of the category you want to show

  5. Miriam Schwab says:

    Hi mgmt – your way works well too. It’s just a matter of either specifying the category slug or ID. Some may find one way easier, some the other, and some may not have a preference one way or the other.

  6. Sean says:

    Hi there, I’m having a bit of a problem with this technique, as soon as I add that new line of code, and I have a <?php else : ?> following the endwhile for a ‘Not Found’ statement, I get this error:

    Parse error: parse error, unexpected T_ENDWHILE in D:\hshome\armadaad\armadadesign.ca\conversation\wp-content\themes\armada\events.php on line 29
    Any thoughts?

  7. Sean says:

    My apologies, the error actually was:

    Parse error: parse error, unexpected T_ELSE in D:\hshome\armadaad\armadadesign.ca\conversation\wp-content\themes\armada\events.php on line 31

  8. Ryan says:

    Sean – You will need to post your PHP here for us to figure out what the problem is. That error message is too general to bugfix from it.
     

  9. Andy Howell says:

    Handy little piece of code :)

  10. Thanks for the tip!  I’ve been working with this today and couldn’t get it to work until you explained it so simply.

  11. Atle says:

    Thank’s for one great blogpst :D

  12. Atle says:

    And I forgot to mention that this solution does not work with me when I used the category name…

    I had to take advantage of category ID to make everything work! Anyway, thanks a lot!

  13. ansel says:

    Thanks so much!  This bit of code was crucial in work on one of my sites.

  14. Perry says:

    im having troubles with this displaying. where do i put it in this code of my template code iv been trying for hours…

    <?php
    /*
    Template Name: Archives
    */
    ?>
    <?php get_header(); ?>
    <div id=”post”>

    <div class=”post-meta” id=”post-<?php the_ID(); ?>”>
    <h1 class=”post-title”><?php the_title(); ?></h1>
    <div class=”postedby”>
    <div class=”post-status”>
    <strong><?php _e(‘Posted by’); ?></strong>&nbsp;<?php the_author_posts_link(); ?> in <?php the_time(‘F jS, Y’) ?>&nbsp;&nbsp;<?php edit_post_link(‘Edit’, ”, ”); ?>
    </div>
    </div>

    <div class=”clear-fix”></div>

    </div>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

  15. Christo says:

    wow thanks mate, this was really helpful.

  16. Christo says:

    If I may be so bold, try putting the loop in front of your code like so:

    START QUERY

    POST

    END QUERY

    your not calling the loop, so it won’t work, try this:

    <!– query needs to be called to display your project category… –>

    <?php query_posts(‘category_name=projects_cat&showposts=10′); ?>
    <?php while (have_posts()) : the_post(); ?>

    <!– the post itself… –>

    <div id=”post”>
    <!– post formatting goes here .. –>
    </div>

    <!– end it… –>

    <?php endwhile;?>

  17. prez says:

    where do u find the templateyou have to edit?

  18. dash says:

    Hi!! exactly what i am trying to do! I want to display all posts from a category (photoshop) in a page; but.. where do i put your phph code?? thank you inadvance!

  19. Ryan says:

    @dash. We can’t help you with that. You need to decided where to put it yourself!

    Without seeing your theme files and knowing where on your page you want it to show there is no way anyone can help.

  20. amanda says:

    Just what I needed, thank you so much! 

  21. vinoth says:

    Here you have given to display the categories. it is a nice one. but what i am asking is how to display the excrepts of the categories we put on this code…
    <?php query_posts('category_name=special_cat&showposts=10'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <!-- Do special_cat stuff... -->
    <?php endwhile;?>

    if change the_post(); to the_excrept(); it won't work.. help me please

  22. Larry Long says:

    When I add this code I can’t password protect the page. I want to add a page that is password protected buy only displays posts from a specific category. Any tips on how I could do that?

  23. Arjan D. says:

    First off, thanks for this really useful tip!

    I have a question though.. How can I make the specified category dynamic. Instead of a static category I want to make it like that, so it chooses the title of the page as a category. Maybe my explanation isn’t so clear so here’s an example.

    I make a new page. It’s called “Juniors“.

    <?php query_posts('category_name=PAGENAME&showposts=10'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <!-- Do special_cat stuff... -->
    <?php endwhile;?>

    Where it says “PAGENAME” in the code, I want to let the “Juniors” show up automatically. Is this possible?

    Thanks for sharing knowledge.

    Best regards

  24. Kenneth Watt says:

    Sorry mate – I think that my problem might be caused by what you are saying here. I want to have multiple ones of this here, but it doesn’t seem to want to change the category for the second one.
    Email me back if you want: kennethwatt(at)technofinger[dot]com

  25. zack says:

    does this work when creating a new page from wordpress or do you have to create a new php file to make this work?

  26. Mike says:

    This worked great for me.

    How should I go about sorting them?  If I want them to be sorted alphabetically, and not by post date.

    I tried &sort_by=title, but that didn’t work.

  27. Mike says:

    Scratch that comment. I figured it out.  &order=ASC or &order=DESC

  28. You can also do this if you want to display posts from a specific category on a specific page

    <?php 

    if ($page_id==11){
    query_posts(‘cat=1&showposts=10′);
    };

    if($page_id==8){
    query_posts(‘cat=3&showposts=10′);
    }

    ?>

  29. Mark says:

    I have a question. How do you have a little box on your site showing say the first 150 words of the latest article of a category other than the one you are displaying on the main page?

  30. Fission says:

    This was such a big help!  I’ve been looking over the difficult-to-traverse WordPress Codex for a while looking for how to do this!

  31. Grif says:

    Hi, thanks for this, however i can’t seem to get it to work.
    Here is the template page code i’m using.
    <?php
    /*
    Template Name: for-sale-template
    */

    get_header(); ?>

    <div id=”content” class=”narrowcolumn”>
    <?php query_posts(‘category_name=homepage&showposts=10′); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class=”post” id=”post-<?php the_ID(); ?>”>
    <h2><?php the_title(); ?></h2>
    <div class=”entry”>
    <?php the_content(‘<p class=”serif”>Read the rest of this page &raquo;</p>’); ?>

    <?php wp_link_pages(array(‘before’ => ‘<p><strong>Pages:</strong> ‘, ‘after’ => ‘</p>’, ‘next_or_number’ => ‘number’)); ?>

    </div>
    </div>
    <?php endwhile; endif; ?>
    <?php edit_post_link(‘Edit this entry.’, ‘<p>’, ‘</p>’); ?>
    </div>

    <?php //get_sidebar(); ?>

    <?php get_footer(); ?>

    Nothing shows on the page even though there are posts in the category called “homepage”.

    Any help appreciated!!!

  32. Grif says:

    OK, found the issue. A plugin called: AStickyPostOrderER

  33. Grif says:

    one other thing, what if i want the normal loop to display also? Is it bad to have 2 loops?

  34. [...] the static page content. I think the following link should help with grabbing the specific loop … code-snip…ies-on-a-page/. If you insert it directly into your pages.php file then you need to make it specific for the page [...]

  35. Rob says:

    Thank you.

  36. Bhaskar says:

    I want to display those posts which do not have any category.Can u help me out?
     

  37. PeterKohl says:

    @Roberto Breve – Thanks …that is by far the easiest I’ve seen as it allows you to only use one .php page yet have multiple WordPress Pages display separate categories…
    Quote:
    <?php
    if ($page_id==11){
    query_posts(’cat=1&showposts=10?);
    };
    if($page_id==8){
    query_posts(’cat=3&showposts=10?);
    }
    ?>

  38. b00m says:

    The code is working…Tnx!

  39. Daniel Fischer says:

    Thank you for this article and tip.   I am having trouble getting it to work.  I entered the following into the HTML portion of a wp page:
    <?php query_posts(‘category_name=COLUMNS&showposts=10′); ?>
    <?php while (have_posts()) : the_post(); ?>
    <!– Do special_cat stuff… –>
    <?php endwhile;?>
    What is supposed to go in the place of  “<!– Do special_cat stuff… –>”
    I’m a bit confused on this part of it.
    Please advise.
    Thank you so much for your help!
    Daniel

  40. Hi guys, first thank you for all those tips!
    I have a little question, how do I remove one categorie from the main page containing all my posts. For example, I’ve made one page containing posts from only 1 category and I would liketo remove this category from my main page.
    Thank you guys for your time!

  41. Nevermind, I just saw the link at the bottom of my post… so stupid :(

  42. chuck says:

    Is it possible to display posts by AUTHORS on a page using same script? What would the query_posts line look like?
    Thanks so much!

  43. jay says:

    Hi, yeah its a handy code and will be using this version.
    But say if i wanted to go one step further and show not just ONE but THREE categories only on a page?

  44. iFadey says:

    It really solved my problem. Thanks :)

  45. Doobie says:

    I noticed that Pagination doesn’t work with this technique… Any clues?
    If I show 1 post per category, the previous posts link opens a page with the same 1 post.  Thoughts?
     
    Thanks.

  46. Cliff says:

    When I enter the suggested code in a new page template file, it works but also removes display of important items like the Page Title and any content that is entered into the Page body.
    In other words, when using this solution I can ONLY show Posts from a selected category on the Page and nothing else.
    For example, I’d like to have a page maintains the Page Title plus some introductory text and then below the display of the category Posts.
    Here’s the code I’m using (sorry no live version to show yet):

    &lt;?php query_posts(‘category_name=shops&amp;showposts=1000&amp;orderby=title&amp;order=asc’); ?&gt;
    &lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;

  47. Aldo says:

    Worked perfect.

  48. I want to have the posts appear on the homepage, with a page of text above the posts. Is that possible using this code?

  49. syncmaster says:

    @Cliff:
    Try adding this before your code:
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    (post stuff here)
    <?php endwhile; endif; ?>
     

  50. Gavin Steele says:

    I have a loop that i use to display a carousel at the top of my site. Currently it displays all entries, but I want to use your code to restrict the outputted images and info to only posts in a specific category.
    Where would I add you code into this loop?

    <?php
    $dock = new WP_Query();
    $dock->query( ‘showposts=8′ );
    while( $dock->have_posts() ) : $dock->the_post();
    ?>

  51. Im going to use it in my blog to display “daily tips” in sidebar.Great piece of code.

  52. mark says:

    Hi,
    Yes, good code… thank you everyone.

    I created a new template and page… using the above code, I was able to display every thing from category “polls” on my new “polls template”.

    However, is there a way to exclude category “polls” from my main template?

    Thank you,

  53. Quinton says:

    It would really help a lot for us newbies if someone can tell us where to use it in the code.

  54. Horst says:

    @Louis – how did you solve the problem  ” how do I remove one categorie from the main page containing all my posts”?
    It is the same to me. Unfortunately I’m not a programmer.

  55. mcloud says:

    Is any of above codes works on HTML pages???

    Thanks

  56. Ivy says:

    You’re brilliant! Thank you!

  57. Chris says:

    Hello, I have gotten this to work but any content that I have on my page gets attached to each individual posting. How can I stop this? Ive tried rearranging the code everywhere but it just does not work.  Is there a break code or something??? Here is my code so far:
    <?php /* Template Name: News
    */ ?>
    <?php global $themeoptionsprefix; get_header(); ?>

    <?php query_posts(‘category_name=featured category #1&showposts=10′); ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php endwhile;?>

    <div id=”content”>
    <?php if(get_option($themeoptionsprefix.’_sidebarpos’) == 1){ get_sidebar(); } ?>
    <?php if(get_option($themeoptionsprefix.’_sidebarpos’) != 2 || get_option($themeoptionsprefix.’_sidebarpos’) != 1 )  { get_sidebar(); } ?>

    <div class=”postarea”>

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    <h2><?php the_title(); ?></h2>

    <br />
    <img src=”http://i813.photobucket.com/albums/zz57/swag411/logo3.jpg” border=”0″ alt=”Photobucket”></a>
    <br />       

    <?php $readrest=__(“Read the rest of this page”,’NewsMagazineTheme640′); $edent=__(“Edit this entry”,’NewsMagazineTheme640′); $pgswrd=__(“Pages”,’NewsMagazineTheme640′); ?>
    <div class=”entry”>
    <?php the_content(‘<p class=”serif”>$readrest &raquo;</p>’); ?>
    <div class=”postareameta”><?php edit_post_link($edent, ‘<p>’, ‘</p>’); ?></div>
    <?php wp_link_pages(array(‘before’ => ‘<p><strong>$pgswrd:</strong> ‘, ‘after’ => ‘</p>’, ‘next_or_number’ => ‘number’)); ?>
    </div>

    <?php
    $commentsonpage=get_option($themeoptionsprefix.’_commentsonpage’);
    if(!isset($commentsonpage) || empty($commentsonpage) || ($commentsonpage == ‘yes’) )
    { ?>
    <?php if ( comments_open() ) : ?>
    <div class=”commentarea”>
    <?php comments_template(); // Get wp-comments.php template ?>
    </div>
    <?php endif; ?>
    <?php } ?>

    <?php endwhile; endif; ?>

    </div><!–end postarea–>
    <?php include (TEMPLATEPATH . ‘/includes/sidebar2.php’); ?>
    <?php if(get_option($themeoptionsprefix.’_sidebarpos’) == 2) { get_sidebar(); } ?>

    </div><!–end content–>

    <?php get_footer(); ?>
    You can check out my website at Swag411.com and click on the news tab to see what I am talking about. Also, how do I give the posts a date, author, and frame? Thanks in advance for the help!

  58. Ethan says:

    I’m having the same problem as Doobie above – the query works great, but pagination doesn’t. In fact, I’m not getting a “previous posts” link at all.
    Ideas??

  59. dandy says:

    I am having the weirdest issue in my entire life. The above code displays results in firefox but not on anyother browser…. this is insane.. its not css/html issue. I’ve looked at the source of page in all browsers. the posts are fetched only in firefox. here is my link. You can check for “Client testimonials”. Only displays in firefox.
    http://webdevelopment.com.sg/dev/allied/
     
    Any help would be appreciated.

  60. Bilal says:

    many thanks dude… wonderful article. Just finished my custom blog with your help!

  61. Gabriel says:

    I hope someone still checks this posts. I read all the posts, but I’m a newbie here. I am using the Basic Simplicity theme and I know nothing about loops or anything. I want to display the 3 latest posts of a category in the home page, but only the excerpts.
     
    Can someone please help me?
     
    Thanks

  62. MoDaD says:

    First of all, thanks for sharing this. It seems to be working great. One thing I noticed was that anything else that came after this in my template would fail to work (such as a series of ifelse items I had in my sidebar). But, I found a fix, which is to make sure the query gets reset when you’re done with it.
    So if you’re having the same problem as I did, add a reset at the end:
    <?php endwhile;?>
    <? wp_reset_query(); ?>

  63. Heather says:

    I love you! Thanks so much

  64. Mattias Lasson says:

    You might want to add “wp_reset_query();” after the endwhile to not possibly mess up other parts of the page. Took me half a day to figure this out. Seems to work now though… thanks.
     

  65. Sory to disturb,
    But :(   I do not understand where to put the code….

  66. Abdul Wakeel says:

    I want to display post through pages . How can i . can you help me out.
    I want to display post on this site
    http://www.islamabadid.com
    Thanks

  67. iN00B says:

    Can we get a working example of this code please? I don’t know what code to put in to display the title, date, category, etc.
     
    Thanks

  68. Tina says:

    Hi, it seems like <?php while ( have_posts() ) : the_post(); ?> this loop is not happening in my website..but I do have posts.. do you know what’s happening?

  69. Kyle says:

    Thanks hey! helped a tonne!

  70. Chris says:

    Hi, has anyone sorted out the pagination issue? I’m experiencing the same problem as Ethan above. Without this working, the code is kind of unusable :/

  71. Manuel Perez says:

    I did it!  Thanks to your post I was able to get my Journal to show only my Journal posts and I was even able to keep my regular posts from displaying my Journal Posts!

    You guys and gals are awesome!

  72. CJ says:

    I’ve tried to duplicate the code for two place holders and found no success on 2.9.1.
     
    Here is the code;
     
    <div id=”left_col”>
    <div id=”cityTitle”>
    <?php query_posts(‘p=1485′);?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?>
    <?php the_content();?> <?php
    endwhile; ?> <?php endif; ?> </div>
    <div class=”space”>
    </div>
    <div class=”box_wrap”>
    <div class=”side_nav”>
    <ul>
    <?php query_posts(‘category_name=Dictionary Sidebar&posts_per_page=1000&orderby=title&order=asc’);?>
    <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post();?>
    <li><a href=”<?php the_permalink(); ?>”><?php the_title();?></a></li>
    <?php
    endwhile; ?> <?php endif; ?> </li>
    </ul>
    </div>
    </div>
    <div class=”space”>
    </div>
    <div id=”cityTitle”>
    <?php query_posts(‘p=1490′);?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?>
    <?php the_content();?> <?php
    endwhile; ?> <?php endif; ?> </div>
    <div class=”space”>
    </div>
    <div class=”box_wrap”>
    <div class=”side_nav”>
    <ul>
    <?php query_posts(‘category_name=Escrow Dictionary&posts_per_page=1000&orderby=title&order=asc’);?>
    <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post();?>
    <li><a href=”<?php the_permalink(); ?>”><?php the_title();?></a></li>
    <?php
    endwhile; ?> <?php endif; ?> </li>
    </ul>
    </div>
    </div>
    <div class=”space”>
    <br />
    <br />
    </div>
    </div>
     
    Then I start debugging the same by removing the first part or the
     
    <div id=”cityTitle”>
    <?php query_posts(‘p=1485′);?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?>
    <?php the_content();?> <?php
    endwhile; ?> <?php endif; ?> </div>
    <div class=”space”>
    </div>
    <div class=”box_wrap”>
    <div class=”side_nav”>
    <ul>
    <?php query_posts(‘category_name=Dictionary Sidebar&posts_per_page=1000&orderby=title&order=asc’);?>
    <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post();?>
    <li><a href=”<?php the_permalink(); ?>”><?php the_title();?></a></li>
    <?php
    endwhile; ?> <?php endif; ?> </li>
    </ul>
    </div>
    </div>
    <div class=”space”>
    </div>
     
    Still found no success with the second section…
     
    Do you know any idea why the WP acts in such a strange manner?

  73. Erica says:

    I just wanted to thank you for this. I am seriously crying tears of gratitude right now. THANK YOU!

  74. decknology says:

    query_posts() breaks pagination.
    might want to let everyone know that in your article.

  75. chike says:

    thanks a lot, made it so easy!

  76. Mr.AD says:

    How about paging ? When use that code, the code
    <?php wp_pagenavi(); ?> is doesn’t works.
     
    Please tell me how to fix it !
     
    Thanks !

  77. Tilo says:

    Thank you. My problem is solved :-)
     
    Greets vom Germany!

  78. dynamodaveo says:

    Spot on guys,

    The reset query keeps all sliders and additional bit in order.
    Thanks a mill

  79. rkcorp says:

    why not use a redirect page template instead? accomplishes the same, and even easier. just takes a beat to load. i dont think the end-user would even notice.

    just add the URL for the category into the page, and then can be a menu item (depending on your permalinks) or added as a submenu.

    http://www.your-site.com/category/catname/

  80. Caro says:

    What If I have an offset within the <?php query_posts-Code? How can I have also the catergory thing added to it?
    This is what the code I have looks like:
    <?php query_posts(‘posts_per_page=2&offset=’.$offset1); ?>
    changing it to:
    <?php query_posts(‘category_name=name’,'posts_per_page=2&offset=’.$offset1); ?>
    destroys the offset. What am I doin wrong?
     

  81. Alex says:

    can we copy this code right in a page? with the right plugin of course

  82. Marieken says:

    Hello,
    Thanks for the code. This is really what I need form my project!
    I just have some trouble getting the ‘reed-more’ link to work. Has this problem occurred before?

    My code is:
    <?php query_posts(‘category_name=blog&showposts=5′); ?>

    <?php while (have_posts()) : the_post(); ?>
    <h3><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”><?php the_title(); ?></a></h3>
    <?php the_content(‘Read on…’); ?>
    <?php endwhile;?>
     
    Thank in advance for your help.
    Marieken

  83. Raphael says:

    Hey guys,

    I’m a bit of a newbie at wordpress.
    But could someone tell me what plugin i should download to make this work?

    Thanks! 

  84. Bibokz says:

    Thanks, I really found it helpful.

  85. Raphael says:

    Nevermind my previous post.
    I already worked it out.

     Thanks for the code!

  86. Anime says:

    How would you go about implementing this in a “Page” though? Not in a template file. As I’m having trouble getting it to display correctly. 

  87. i try to put this code at home page (index.php)
    <?ph’
    query_posts(‘cat=-990,-1610,-995,-991,-613,-116,-29&showposts=10′);
    if (have_posts()) :
    while (have_posts()) : the_post(); ?>
    thats look OK, but i got error with navigation and search query.
    when i try to click next page…we can see only first page again,  when i try to search post using search form…only display list post from first page.
     
     

  88. Jap says:

    Its 2012 the pagination issue is not yet solve. Any Idea?

  89. Jap says:

    Ok here is my solution to the pagination issue, I just stumble upon it here:
    http://wpquestions.com/question/show/id/1790
    Instead of

    <?php query_posts('category_name=special_cat&showposts=10'); ?>
    Make it
    <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; query_posts(‘posts_per_page=10&cat=8&paged=’.$paged); ?>

  90. Martijn says:

    Thanks man! This helped me alot. Now i can continue to build my website. I have to figure out though to just show a max. of characters and then show some tekst like “read more” have any ideas?

  91. Hi Miriam,

    Could you please show me a piece of code where i could select the attributes of the things i want to be shown from posts in certain other pages? Like thumbnail, description, excerpt. 

    Thank you! 

Leave a Reply




If you want a picture to show with your comment, go get a Gravatar.

More in Code Snippets, WordPress as CMS (33 of 50 articles)