Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8745327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:59:21+00:00 2026-06-13T11:59:21+00:00

The following query is not working on the WordPress author.php template for my theme.

  • 0

The following query is not working on the WordPress author.php template for my theme. Its included in the footer which is the same footer across all pages and the query works fine on every other page except for author.php

  <?php if(have_posts()):?>
  <?php query_posts( array( 'post_type' => 'connect' ) ); while (have_posts()) : the_post(); ?>
  <div class="title"><?php the_title();?></div>
  <div class="logos">  
  <?php the_content();?>
  </div>
  <?php endwhile;?>
  <?php wp_reset_query(); ?>
  <?php endif;?>

I have spent more than an hour trying to figure out what is going on and why this isn’t working, but I now feel like I am banging my ahead against concrete. Why isn’t it working?!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:59:22+00:00Added an answer on June 13, 2026 at 11:59 am

    In order for me to explain why it’s only working on some of the pages, you need to understand what query_posts() actually does.

    query_posts() modifies the default WordPress Loop. No matter what page you’re on, there is ALWAYS a default Loop initialized by the Core. Unless your intention is to modify that loop, it is imperitive that you stop using query_posts() altogether.

    There are MANY reasons why query_posts() is misused so often, and they have been detailed out in many forums as well as in the WordPress Codex itself. But that’s getting into an area that is irrelevant to your question.

    First off, let’s look at what your code is doing:

    <?php if(have_posts()):?> //If the default loop finds posts....
    <?php query_posts( array( 'post_type' => 'connect' ) );?> //Modify the loop to fit these new parameters
    

    Basically, your new query will only run if the Default Loop is able to return a set of results. This works on other pages, because the Default Loop will generally work in most scenarios.

    It’s not working on your Author.php template because, for whatever reason, it’s not able to return a set of results to then run your modified query.

    So how do you fix it?

    You need to change your structure, and how your queries are called. I don’t know how deep into the project you are, and if this is something that is on a pretty tight deadline with a client, but my advice would be to scrap any and all query_posts() calls in favor of WP Query

    Does it look a little more complicated? Sure. But making this your bread and butter of any current and future WordPress themes will end up saving you a LOT of time and trouble.

    The bad way:

    <?php
    query_posts( array( 'post_type' => 'connect' ) );
    if(have_posts()): while (have_posts()) : the_post();
    ?>
    <div class="title"><?php the_title();?></div>
    <div class="logos">  
    <?php the_content();?>
    </div>
    <?php
    endwhile;
    wp_reset_query();
    endif;
    ?>
    

    The proper way:

    <?php
    $q = new WP_Query( array( 'post_type' => 'connect' ) );
    if($q->have_posts()) : while($q->have_posts()) : $q->the_post;
    ?>
    <div class="title"><?php the_title();?></div>
    <div class="logos">  
    <?php the_content();?>
    </div>
    <?php
    endwhile;
    wp_reset_postdata();
    endif;
    ?>
    

    Hope this helps, and good luck.

    UPDATE:

    WP_Query does allow you to query posts by author, and your assumption that default values provided within a new WP_Query object will typically reflect the default query on a given page seems to make sense, and can potentially explain the behavior you’re seeing.

    Since the WP_Query documentation doesn’t really provide a way to explicitly search for author type ‘any’, we may have to get our hands a little dirty on this one:

    $user_ids = get_users(array('who'=>'author', 'fields'=>'ID'));
    $q = new WP_Query( array( 'post_type' => 'connect', 'author'=>implode(',', $user_ids) ) );
    

    Let me know if that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Order by descending is not working on LINQ to Entity In the following Query
The following query is not working the way I expect: SELECT DISTINCT * FROM
I have the following query and it's not working exactly as i want it
I have the following query in DB2 but is not working, the problem is
I have the following query that is not working: PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema%23> PREFIX i:
I'm working in SQL Server 2000. The following query is not working declare @TempAccountKey
Using the following query, I can't figure out why my update is not working.
The following sql query is not working. select UserName from [User] where UserID Like
The following query is not working from visual Studio: var query = this.ObjectContext.Questions.Include(AnswerKey).Where(o =>
I have the following (not working) query: insert into [MyDB].[dbo].[Reports_StepsStat] (ActivityID,TaskID,StepIndex,StepStatus,TimeSpanInSeconds,Score) VALUES ( SELECT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.