• Resolved robgrayson

    (@robgrayson)


    I’m in the process of putting together my first WP site. I’m using the “Autumn Concept” theme, with a few modifications. I know nothing about php, but after a few hours’ googling have managed to achieve the desired result…almost.

    The main change I have made is that I’ve created a specific category called “news”, and excluded any posts assigned to that category from the main page; I have also created a static page called “news”, which only displays posts assigned to the “news” category. Both these changes work OK in terms of only showing the posts they should.

    The problem comes with post order. On the “news” page, the two test posts I’ve created are shown in the correct order – i.e. most recent first. But on the main page, my two test posts show in reverse order (oldest first). I’ve done some digging around and found references in WP forums to a MySQL bug – but that wouldn’t explain why this is only happening on the main page and not the “news” page.

    Finally, I’ve tried to correct this by putting a “query_posts” statement at the start of the loop in the main page (index.php) that sets the sort order to descending. It doesn’t make any difference. (Maybe because I’ve already inserted a “query_posts” statement to exclude posts in the “news” category?)

    Probably easier to see if you have a look at the site: here.

    Fingers crossed someone can tell me how to change this…thanks in advance.

    Rob

Viewing 15 replies - 1 through 15 (of 17 total)
  • What version of MySQL are you (or your host) using?

    In phpMyAdmin you can usually see the version.

    Or this SQL command

    SHOW VARIABLES;

    Thread Starter robgrayson

    (@robgrayson)

    Hi Michael,

    According to my host’s control panel, it’s MySQL version 5.0.

    Rob

    If your problem isn’t this:
    https://www.ads-software.com/support/topic/154622?replies=6

    then your theme may be showing those posts intentionally in reverse order.

    You might look at your theme’s index.php file to see if that is the case. Look for something using query_posts.

    If necessary, you may need to post your theme’s index.php in a pastebin and report the link back here.

    Thread Starter robgrayson

    (@robgrayson)

    Michael,

    I don’t know what the problem is…but I’m assuming its not the MySQL problem you linked to, since it only occurs on my main blog page and not on my news page, where posts are correctly shown most recent first.

    I can’t find any instances of query_post apart from the ones I’ve put in to exclude posts in the “news” category from the main page and to include only posts in the “news” category on the news page.

    As suggested, I have pasted the code from the index.php file here.

    Appreciate any suggestions…let me know if I need to post anything else.

    Thanks,

    Rob

    Thread Starter robgrayson

    (@robgrayson)

    Anyone ?

    Thread Starter robgrayson

    (@robgrayson)

    Update: I’ve now installed phpMyAdmin via the excellent wp-phpMyAdmin plugin, and I can confirm that my server is running MySQL version 5.0.51 – which is the version reported to cause problems with posts appearing in reverse order.

    BUT, the posts on my “News” page appear in the correct order. Why are posts on this page behaving differently? And if the posts on this page appear in the correct order, surely there must be something I can do on the main page to achieve the same result?

    Rob

    Beats me. I copied your code for index.php and used it on my localhost. Set cat id to 1 and the home page does show posts from all the other categories in descending order.

    Thread Starter robgrayson

    (@robgrayson)

    Hi Srikat,

    Well, thanks for trying anyway. So my index.php code worked OK without modification on your host? Bizarre…

    What I don’t get is that even if this is caused by a bug in MySQL 5.0.51, the fact that posts are displaying correctly in descending order on my “News” page proves that the problem is not insurmountable. But how to fix it… (scratches head in frustration…)

    Rob

    Thread Starter robgrayson

    (@robgrayson)

    Well, I have found a solution…or rather a workaround: another way of achieving the desired result.

    Obviously my query_posts statement to exclude posts in one category in index.php was causing a problem with the post order, and while ever that statement was there, I couldn’t find any way of getting the posts back into descending order. So I put the index.php file back as it was originally, and then installed the Advanced Category Excluder plugin, which successfully removes the desired category from the front page without changing the post order.

    Got there in the end!

    Rob

    I have this same issue. Using MySQL 5.0.51, anytime I try to use query_posts and EXCLUDE a category, it shows them in the wrong order. If I only try to include a category or limit the number of posts, it works fine and shows them in the correct order.

    Even using order and orderby, I can’t get posts to display in the correct order while excluding a category.

    I don’t think this is something I should have to install a separate plugin for. Anyone have any idea? ??

    running multiple loops? – try doing rewind_posts() prior to your errant loop to reset the post counter.

    I dont know if this has any bearing, but I’ve had occasions where posts were shown out of order because the post counter had been set in a previous loop

    I do have multiple loops, but rewind_posts() didn’t do anything. :-/

    I use query_posts twice on the main page. It was working until (of course) I upgraded WAMP, which included the new version of MySQL.

    check out get_posts() for the auxiliary loop, it may do what you want, and is actually lighter on queries. It also won’t interfere quite so much with your main loop.

    Defect MySQL version…
    See this post: https://www.ads-software.com/support/topic/154622

    So 5.0.51 is “bad”, but it’s also the newest stable release? That’s kind of frustrating.

    Has anyone had luck running 5.1 or 6 with WordPress on Windows?

    Thanks for trying, Ivovic.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Posts displaying in wrong order…but only on main page’ is closed to new replies.