• I’m currently working on a site where markup is of outmost importance. The site navigation is really simple, showing only 10 posts on the front page with no pagination, and having an “archives” page where all the posts display. The archives page has the following markup:

    <h2><span>Month/year</span></h2>
    <ol>
    	<li><a href="permalink">
    		<img src="image.jpg" alt="featured image" />
    		<time pubdate="" datetime="2011-01-18" class="published">10 january 2011</time>
    		<h3>Post Title</h3>
    	</a></li>
    
    	...
    </ol>

    As I said before, the markup for this particular project is very important and cannot change, so that’s a bit of a problem.

    So, I’ve come to the conclusion that the only solution is either a (probably hacked) plugin, which I rather not; or a custom query to the database. I’m in no way an advanced programmer, and I’ve failed to achieve this. Anyone has an idea? I’m not even sure how to call a custom query to the DB from a template file.

    Thanks in advance!

Viewing 5 replies - 1 through 5 (of 5 total)
  • If I’m understanding this correctly, you want the archives page to show infinite posts while the actual posts page only shows 10.

    If that is correct, you’ll have to define a custom query on the archives page using query_posts.

    For example:
    <?php query_posts('posts_per_page=-1'); ?>

    Consult the query_posts codex doc for complete usage instructions.

    Thread Starter enrique-ramirez

    (@enrique-ramirez)

    Yes, something like that.

    What I want is this code:

    <h2><span>Month/year</span></h2>
    <ol>
    	<li><a href="permalink">
    		<img src="image.jpg" alt="featured image" />
    		<time pubdate="" datetime="2011-01-18" class="published">10 january 2011</time>
    		<h3>Post Title</h3>
    	</a></li>
    
    	...
    </ol>

    On a per-month basis, without having to do a manual, custom query for each month. Right now, I’m doing this:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Which works, but it’s messy, and every month I need to edit the file. This could also be, in a while, very messy to deal with.

    Thread Starter enrique-ramirez

    (@enrique-ramirez)

    ^ Code I’m currently using is here:

    http://wordpress.pastebin.com/kL0ivd8R

    Still having a tiny bit o’ trouble trying to figure out exactly what you’re trying to do. Is it something similar to the left column of my archives page at http://www.chriseverson.net/archives/?

    If so I can send you that code to pick apart.

    Thread Starter enrique-ramirez

    (@enrique-ramirez)

    Hi Chris,

    Yes, that’s pretty close to what I’m trying to achieve. If I can change the div’s you’re using to other tags, that’d be perfect.

    Here, let me show you the page I’m trying to build.
    http://files.enrique-ramirez.com/H/html5doctores/archives.html

    Hope this gets things clearer for you. 🙂 It’s a simple page, but I haven’t found a way to do it keeping the same markup yet.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom query for archives display?’ is closed to new replies.