Support » Fixing WordPress » unable to alter index.php query

  • My index.php file is bent on displaying my posts in some seemingly random order. I have tried changing the query using query_posts. I have tried deactivating all of the plugins. I have tried the baseline theme…all to no avail. I even tried writing a totally separate query like this:

    <br />
    <?php<br />
    $page = (get_query_var('paged')) ? get_query_var('paged') : 1;<br />
    $mainQuery = new WP_Query();<br />
    <p>?><br />
    <?php while ($mainQuery->have_posts()) : $mainQuery->the_post(); //main query was returning randomly ordered posts ?><br />

    I’m stuck. Please help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Michael


    Forum Moderator

    did you get any error messages?
    is this really your code, or did the
    tags get added through copy/paste?

    the code you posted should look like:

    $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $mainQuery = new WP_Query();
    <?php while ($mainQuery->have_posts()) : $mainQuery->the_post(); //main query was returning randomly ordered posts ?>

    and should be used in a page template or one of the template files such as index.php.

    you could paste the code of index.php of your theme into a and post the link to it here.
    someone might have a look at it and may have some suggestions.

    a link to your site to illustrate your problem might also help.

    Sorry about that cut and paste problem. I pasted my index.php file here:

    I can’t link to my site becuase it’s under maintenance and not public yet. Any thoughts would be helpful. I’m baffled at this point. Do you think that it could have something to do with my site being in the “/blog” directory(though the site resolves to the root, that’s where the files are stored) and my permalinks category base being “blog”. I did this for continuity of links ages ago, but it was never a good solution and i can’t change the name of the root folder now…well, i guess i could, but that would require some solid SQL.


    I’m familiar with giving wordpress its own directory…it already has one. I switched around the category permalink base to no affect. It’s really strange what’s happening…I’ve been working with wordpress installs for 5 years and this has yet to occur.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘unable to alter index.php query’ is closed to new replies.