• Resolved cyberlp23

    (@cyberlp23)


    Hello,

    I have created a menu item that links to a custom taxonomy archive.
    The page should therefore display all the articles from this taxonomy — which it does, except for some of the articles that are not displayed.
    How is that?
    I’ve checked the articles, and none of the ones not displayed seem to be different in any way.

    Any idea?

    Thanks!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Moderator bcworkz

    (@bcworkz)

    I suggest you examine the actual SQL query run for a clue to why you are not getting expected results. Of course, this requires you to have some understanding of SQL query code. Reading it is a lot easier the writing, it ought to make some sense, even without any SQL knowledge.

    Determine what template is used for the archive listing. Insert the following code to have the SQL appear on the page.

    <?php
    global $wp_query;
    echo '<pre>';
    echo $wp_query->request;
    echo '</pre>';
    ?>

    Avoid placing this within “the loop”. No harm in doing so, you’ll just get the same SQL output multiple times.

    Thread Starter cyberlp23

    (@cyberlp23)

    SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND (
    wp_term_relationships.term_taxonomy_id IN (2387)
    ) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_status = 'private') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 28

    It appears normal, doesn’t it?

    Moderator bcworkz

    (@bcworkz)

    Indeed. Are you sure all articles are assigned the term with ID 2387? Might there be other terms assigned in your taxonomy besides term ID 2387? The archive lists all posts assigned a specific term, not all posts assigned any term in the taxonomy.

    Thread Starter cyberlp23

    (@cyberlp23)

    This is really weird.
    I’ve checked 2 similar articles: both are assigned with term ID 2387 (and no other terms).
    One appears in the archive page, the other does not.
    Even in the WordPress back office, in the 2387 taxonomy articles list, not all articles tagged with 2387 appear.
    And the problem is not just for 2387, same thing happens with other terms.
    I’ve tried uncheck the term, save the article, check & save again, but nothing changes.

    Moderator bcworkz

    (@bcworkz)

    Check the list of posts returned in the global $wp_query->posts. All posts assigned the term should be there. It’s what drives the loop on templates. If all are there, there is something on your templates filtering output. If not all there, something is strange with the DB table or SQL that is beyond my comprehension.

    Thread Starter cyberlp23

    (@cyberlp23)

    Check the list of posts returned in the global $wp_query->posts.

    Sorry, but how should I check that? ??

    Moderator bcworkz

    (@bcworkz)

    Ah, sorry for lack of clarity. Replace the echo $wp_query->request; from the prior code I gave you with print_r( $wp_query->posts );. The output for each post will be extensive. Within the output will be familiar items for each post like ID, title, content. Your task is to determine if any posts assigned term ID 2387 are missing from the list.

    Thread Starter cyberlp23

    (@cyberlp23)

    Ok yes I understand!
    So, no, not all the posts are displayed.
    I guess I’ll have to look further into the database to see what’s happening… ??
    Thank you for your help anyway.

    • This reply was modified 5 years, 2 months ago by cyberlp23.
    Moderator bcworkz

    (@bcworkz)

    No problem, good luck, I hope you find the glitch.

    Thread Starter cyberlp23

    (@cyberlp23)

    I just found out where the problem comes from!

    An update of the ACF (custom fields) plugin deactivated the option to automatically link a post and the taxonomy terms… I reactivated the option and it works again.

    My only issue now being that in order to have the terms to be displayed for older posts, I have to open them one by one and save them again. I tried to bulk edit them, but it didn’t change anything when I saved them. Any idea as to how I could do?

    Well at least the main problem is solved!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Custom taxonomy archive: not all posts displayed’ is closed to new replies.