WordPress.org

Ready to get started?Download WordPress

Forums

unable to alter index.php query (5 posts)

  1. greggo
    Member
    Posted 4 years ago #

    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 />
    $mainQuery->query("showposts=10&orderby=date&order=DESC&paged=$page");</p>
    <p>?><br />
    <?php while ($mainQuery->have_posts()) : $mainQuery->the_post(); //main query was returning randomly ordered posts ?><br />

    I'm stuck. Please help.

  2. alchymyth
    The Sweeper & Moderator
    Posted 4 years ago #

    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:

    <?php
    $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $mainQuery = new WP_Query();
    $mainQuery->query("showposts=10&orderby=date&order=DESC&paged=$page");
    ?>
    <?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 http://wordpress.pastebin.com/ 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.

  3. greggo
    Member
    Posted 4 years ago #

    Sorry about that cut and paste problem. I pasted my index.php file here: http://wordpress.pastebin.com/gJPhRkEv

    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.

    thoughts?

  4. esmi
    Forum Moderator
    Posted 4 years ago #

  5. greggo
    Member
    Posted 4 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic