• OK – I’ve done my searching and I’ve read the Codex and like it or not, it looks like I am going to have to wander into PHP code territory, but I know you guys have a reputation for being gentle, right? ??

    After a few days of being a dolt, I managed to get an Archives Index page running with Smart Archives. Sweet!

    What I *really* want to do is create one single list, perhaps (looking ahead) per Year, but sorted by alphabetic name of the Post Title, and then obviously linking to the post itself.

    I followed a rake of links from my searches here, and in the Codex and settled on this bit of code (can’t remember where I found it):

    <?php
    wp_get_archives('type=postbypost&sort=post_title&order=ASC');
    ?>

    This is *nearly* there – I get the single list of posts (presumably per Year, but I only have 2005 entries thus far), but the list is *not* in total alpha order – it seems rather to be still ordered by month, but in no Alpha order I recognise.

    Happy to force myself to learn more PHP, so some pointers would be good … or the right answer and some pointers too! :o)

    Thanks!

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter cloudhopper

    (@cloudhopper)

    Polite .bump

    Any pointers on this one?

    The example code I cited above is from the Codex entry on “Alphabetizing_Posts” and results in a combined list (of all archives) -which is *close* to what I would like to do – but is still apparently in chronological entry order.

    There is another example of code on the same page which simply results in a “parse error” when I try to include it.

    Unlike other posts I have spotted here today, I am willing to increase my PHP and CSS knowledge (and am enjoying that) but I seem to have reached a personal brick wall on this one :o)

    Any help appreciated. Ta!

    Which version of WordPress are you using?

    Thread Starter cloudhopper

    (@cloudhopper)

    1.5.1.3 – latest stuff : )

    The Alphabetizing_Posts examples should “just work”. Does the first example work (using get_posts()) ?

    Thread Starter cloudhopper

    (@cloudhopper)

    There are four examples on the “Alphabetizing Posts” page – the first three all return “Parse error: parse error, unexpected $” when tried – only the fourth example, cited in Post 1, works at all (for me!).

    I quite expect that this is a result of me not knowing what the hell I am doing, but then that would be fairly and squarely in the context of my cry for help & guidance!

    If it helps further, I am using the Archives template from the Letterhead theme – I just dumped out all the existing Archives code from the Div id=content area – leaving a header and a footer – and popped in the code in Post 1. In the same circumstances, the “parse error” occurs for the other examples.

    A parse error indicates that you’ve incorrectly copy-and-pasted the example. Can you paste the entire block that you’re trying to use, so we can look for minor syntax errors?

    Thread Starter cloudhopper

    (@cloudhopper)

    Well, I may have trouble understanding what’s going on with CSS sometimes, and definitely am in the woods when it comes to PHP, but I’ll be pretty disappointed if it turns out that I have not, as I always thought, mastered the art of cut&paste!

    Here’s what I have – straight from the page of the Codex – and taken via Notepad, just in case there were any hidden characters lurking:

    ‘<?php
    // we add this, to show *all* posts sorted
    // alphabetically by title
    $posts = query_posts($query_string . ‘&orderby=title&order=asc&posts_per_page=-1’);
    // here comes The Loop!
    if (have_posts()) : while (have_posts()) : the_post(); ?>’

    Sure enough. This gets me the parse error – context as described two posts above – simple page: header, footer, content div.

    (Appreciate you returning to this, I used up my bump already!)

    Stupid question, but… Do you have the rest of the Loop in your file? (because the example in the Codex shows only the start line of the Loop!)

    What happens if you remove the $query_string from inside the query_posts() ?

    Thread Starter cloudhopper

    (@cloudhopper)

    Moshu – hmm. Forgive me, when one cut&paste example works, I kind of assumed….

    ..so I followed the link to The Loop and added the code entitled “and ends here”.

    So now I don’t get the parse error, but neither do I get anything else. (Stamps foot: surely an example in the codex might be expected to…. pfft. Sorry!)

    Skippy: tried taking out “$query_string .” (but left the end of the loop in place). No parse error, but no nothing else neither. : (

    Coffee’s on – want one?

    Okay; get_archives is hard coded to use post_date with postbypost.

    /wp-includes/template-functions-general.php, line 344ish:
    } elseif ('postbypost' == $type) {
    $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
    if ($arcresults) {

    The quick-and-dirty fix is to modify that function; but then you’ll need to re-apply this change after every upgrade.

    I filed a bug report about this almost a year ago. Go add your comments to that note so that it might get resolved. =)

    Thread Starter cloudhopper

    (@cloudhopper)

    Thanks Skippy, I’ll have a play with that.

    Slightly OT, but relevant in context: it is in areas such as this that WordPress scores so strongly for me, in that it is causing me to *want* to learn about CSS and PHP, so that I can make *my* bit of the web do what I want it to do.

    The downside is that occasionally, the easy cut&paste stuff takes you into deeper water – and you know that panicky feeling when you suddenly realise you can’t feel the bottom any more?!

    Anyway, I recognise that the support and documentation is developing apace, and *respect* to all you guys who are so phenomenally patient and generous in these forums. I am genuinely impressed with not only the software, but the whole attitude that surrounds it.

    I’ll report back on that fix, once I’ve eased the brain-ache a little :o)

    Thread Starter cloudhopper

    (@cloudhopper)

    Skippy is the man!

    Changed the code referred to (2 posts above) to read:

    ORDER BY post_title ASC”

    and sure enough, the code filched from the Codex (see Post#1) now works – listing *all* my posts, by title, in Alpha order. (I now have to work out why some of the posts don’t seem to obey the rules of alphabetic order, but that’s another game!).

    I will add a comment to the bug report – if I am allowed.

    Signing out note: if someone works out whether the other codex examples (the ones with the parse errors) actually work, or need some ammendment, it would be nice to know. :o)

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Alphabetic index of posts’ is closed to new replies.