• I have this code in my theme, but for some reason itsn’t displaying nothing:

    <?php
        global $query_string;
        query_posts($query_string . "posts_per_page=".get_option('onthego_fromblog_random')."&ignore_sticky_posts=1&orderby=rand&cat=".get_catid(get_option('onthego_blog_cat')));
    ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <?php get_template_part('includes/fromblog_post'); ?>
    <?php endwhile; endif; wp_reset_query(); ?>

    I’m trying to find where the problem is and for that I enabled at wp-config.php: define('WP_DEBUG', true); and define('SAVEQUERIES', true); and after I install wordpress debug_bar plugin but queries aren’t clear to me, is there another way yo look for a raw SQL just for this piece of code or any other way to troubleshooting this issue? Or I have something wrong in my code and I don’t see it?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You could hook ‘posts_request’ and print_r() the passed SQL query. You will only see WP_Query queries this way. If you print_r() within <pre> tags you should be able to see the output, if not, view the HTML source.

    You might consider using the array format of arguments to query_posts(). it’s easier to construct a structured array and see possible syntax errors than with the string format you are using here. There may be an error there, but it’s hard for me to see them with this format.

Viewing 1 replies (of 1 total)
  • The topic ‘Troubleshoting query_post(), how to get the current or last SQL query performed’ is closed to new replies.