Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with query on wordpress 4.6.1 #379

Closed
RoccoMarco opened this issue Oct 22, 2016 · 16 comments
Closed

Problem with query on wordpress 4.6.1 #379

RoccoMarco opened this issue Oct 22, 2016 · 16 comments

Comments

@RoccoMarco
Copy link

RoccoMarco commented Oct 22, 2016

Dear all,
I have read on the web about this issue and it seems I am not the one experimenting this issue.

I was working with the latest version of co-author plus (3.2.1) experimenting this issue: making a query of post count related to an author the result is 0!

Query based on author doesn't include coauthor results... I have take a look to bug #374 and updated the plugin to the development version. Problem still unsolved...

@mjangda
Copy link
Member

mjangda commented Nov 8, 2016

I was working with the latest version of co-author plus (3.2.1) experimenting this issue: making a query of post count related to an author the result is 0!

I'm not sure I understand. Can you share the code you're using to do the query?

@trepmal
Copy link
Contributor

trepmal commented Nov 11, 2016

Hi @RoccoMarco, I just wanted to follow up on @mjangda's request. Would you be able to share the code you're using for the query?

@RoccoMarco
Copy link
Author

    $args = array(
      'author'  => $authID,
      'posts_per_page' => 50,
      'post_type' => 'post',
      'post_status' => 'publish'
    );
    query_posts($args);

    echo '<ul class="post-list">';
    // Start the Loop.
    while ( have_posts() ) : the_post();
      echo  '<li><h3><a class="title-link" href="'.get_the_permalink().'">'.get_the_title().'</a></h3></li>';
    // End the loop.
    endwhile;
    echo  '</ul>';

This return should return a list of article related to the author identified by $authID. It seems like list misses all the articles coauthored by $authID. An article appear in the list only when author is the "first" author of it.

@trepmal
Copy link
Contributor

trepmal commented Nov 17, 2016

Hi @RoccoMarco, thanks for the info.

The query is not going to work as expected with the author argument. There's a deeper issue here with how Co-Authors Plus intercepts the query to include additional authors (#374 (comment)).

For your case, try to use author_name instead.

(As a separate note: in most cases query_posts() is not what you want)

@RoccoMarco
Copy link
Author

Actually I have already tested this path. Using
author_name => nicename
result is all posts from every author. Maybe I am missing something.

@trepmal
Copy link
Contributor

trepmal commented Nov 21, 2016

So far I've been unable to reproduce the behavior you're describing.

Here's the code I'm using to run some tests:

$args = array(
	'author_name' => 'guest-author',
);
$nq = new WP_Query( $args );

echo '<pre>';
var_dump( $nq->request );
echo '</pre>';

echo '<ul class="post-list">';
while ( $nq->have_posts() ) : $nq->the_post();
	echo  '<li><h3><a class="title-link" href="'.get_the_permalink().'">'.get_the_title().'</a></h3></li>';
endwhile;
wp_reset_postdata();
echo  '</ul>';

In my test site, guest-author is mapped to a real user. I've also used an unmapped real user, and an unmapped guest author, all of which have produced the expected results.
Additionally, each have at least one post where they are the only author, and another where they are a coauthor.

If you haven't already, are you able to deactivate any other plugins you are using and switch to the default theme? This could help narrow down any conflicts.

@trepmal
Copy link
Contributor

trepmal commented Nov 21, 2016

@RoccoMarco You also commented on #374, would you be able to test the pending fix #381 (it's not a big change if you need to apply it manually) and see if it resolves your issue?
Perhaps another plugin is adding a tax_query automatically?

@RoccoMarco
Copy link
Author

RoccoMarco commented Nov 22, 2016

Pending fix doesn't solve my issue. Thanks a lot for your interest and help.

Edit: pending fix solve my issue if I use user_nicename instead of user_ID

@trepmal
Copy link
Contributor

trepmal commented Nov 22, 2016

Edit: pending fix solve my issue if I use user_nicename instead of user_ID

This sounds promising. Can you confirm if any of your active plugins or theme is adding a tax_query automatically? That will be helpful in determining if this issue is the same as #374

@RoccoMarco
Copy link
Author

RoccoMarco commented Nov 22, 2016

Hard to tell. How can I get this information?

Edit: thinking on it, I suppose Polylang is doing this (a tax_query related to language)

BTW the website is playembedded.org

@trepmal
Copy link
Contributor

trepmal commented Nov 25, 2016

Could be, I don't have any experience with that plugin.

If you were to undo the patch and deactivate Polylang, do you still have the reported problem?

If that doesn't do it, I'd again start with removing the patch/pending fix and deactivating all plugins. Then reactivate one-by-one and see if the issue returns. When/if it returns, that'll narrow down which plugin is in the way.

@RoccoMarco
Copy link
Author

I am sorry but right now I cannot disable the plugin. I have to put website in maintenance mode to do this risking to screwed up everything.

I will made a local copy to do accurate tests in the weekend.

@trepmal
Copy link
Contributor

trepmal commented Nov 25, 2016

No problem, and no rush. Enjoy your weekend :)

@philipjohn
Copy link
Contributor

Hi @RoccoMarco did you get any time to take a look at this?

@RoccoMarco
Copy link
Author

RoccoMarco commented Jan 15, 2017

Actually I have forgotten it :( . I will make some tests but right now I have not enough spare time.

@GaryJones
Copy link
Contributor

I'll close this out on the assumption that we've all moved on from WP 4.6.1 and CAP 3.2.1, but if the problem still exists, please open a new Issue.

@GaryJones GaryJones closed this as not planned Won't fix, can't repro, duplicate, stale Jul 22, 2023
@GaryJones GaryJones removed this from the KL milestone Jul 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants