page w/ posts - pagination - twenty eleven (4 posts)

  1. connectto
    Posted 2 years ago #

    so i have a page that shows all post from a selected category


    but need to have a pagination in this content, so it would show just 4 posts in each page

    im using a copy of twenty eleven, heres my code for this page


    also have some problem in my content background - should be black with some transparency as my home http://www.connectto.com.br/websites/ - but this bg isnt there ...

    help please ! :D

  2. Michael
    Part-Time Forum Moderator
    Posted 2 years ago #

    your chosen file name category-portfolio.php might get interpreted by the template hierarchy as a category template; http://codex.wordpress.org/Template_Hierarchy

    basically, you are telling your template to show a 1000 posts per page:

    <?php $archive_query = new WP_Query('cat=3&showposts=1000');


    start by changing that to 4, and then add the 'paged' parameter; example:

    <?php $archive_query = new WP_Query('cat=3&posts_per_page=4&paged='.get_query_var('paged'));

    then review:

    for example, add some code like this in line55 of the pastebin code or after the endif of the loop (might need added html for formatting reasons):

    <?php previous_posts_link('« Newer Entries', $archive_query->max_num_pages); ?>
    <?php next_posts_link('Older Entries »', $archive_query->max_num_pages); ?>


  3. connectto
    Posted 2 years ago #

    ok alchymyth, thanx for your help, really , dont know other place to learn this stuff !

    so i changed the number from 1000 to 4, and also change my page number to portfolio.php .. also change the template name from category-portfolio to `Template Name: portfolio

    and added the pagination code at the end

    but now my background works but the posts from my category called "portfolio" disapeared ..

    thats the problem, and thats why i thought i should call this page category-portfolio ... because i need to show the posts from this category in this page..


    it would help me a lot now know how is the correct way to show my posts from category "portfolio" and background, pagination, etc , without mess with the wordpress template hierarchy using the name category-portfolio.php .. just need to know that hehe

    i have some problem to understand correctly this wordpress texts about their structure and how it works... im not a professional programmer and also my english is little poor .. i understand the text but it dont give me ideia about how to put this in the codes ...

    thanx for your help

  4. connectto
    Posted 2 years ago #

    sorry just forget to say

    u can see how it is right now here http://www.connectto.com.br/websites/portfolio/

    and heres the code http://pastebin.com/BHTzr06u

Topic Closed

This topic has been closed to new replies.

About this Topic