Custom Fields
Re-Envisioned
Support MB Views How to show all posts for specific taxonomy?

  • Creator
    Topic
  • #21511
    Resolved EddyPiV
    Participant

    Hi,

    I am trying to show all posts for a specific taxonomy, but I am getting only the current page.
    This is what I did:
    My template settings: https://share.getcloudapp.com/bLuR5K6X
    My settings: https://share.getcloudapp.com/RBuOZn7L

    Because I want similar archive views for each value of the taxonomy, I have created a page per taxonomy, with the shortcode of the view in it.

    But the result is that I only see that page containing the shortcode with the view, actually: my current page.

    What is it that I am doing wrong?

Viewing 10 replies - 11 through 20 (of 26 total)
  • Author
    Replies
  • #21633
    Long Nguyen
    Moderator

    Hi,

    With the custom query, we have to use the variable of the post object. Example:

    See more in this documentation https://developer.wordpress.org/reference/classes/wp_post/.

    In the code set args, the field should be slug (term slug is rotterdam) instead of location, see more in this documentation https://developer.wordpress.org/reference/classes/wp_query/#taxonomy-parameters.

    #21691
    EddyPiV
    Participant

    Hi,

    I am confused, I still couldn’t figure out how to get all posts for a specific value of a taxonomy.
    It looks like my view is ignored at all.

    This is the view: https://share.getcloudapp.com/12uJlQwX
    This is the location: https://share.getcloudapp.com/Z4ukNpQ8,
    This is the value for the taxonomy: https://share.getcloudapp.com/RBuOAkKL
    This is the result: https://share.getcloudapp.com/nOuk7JBw
    It shows just all posts, pages and cpt’s for this value of the taxonomy. Also, the initial text “This is the archive view” does not appear.

    Your help is much appreciated…

    #21692
    EddyPiV
    Participant

    Actually, I believe I don’t understand how the location works in relation to the url of the acrchive page.
    Just a simple location is okay, but once it gets more (AND / OR relations) I am lost.
    Although in the case above, even with a single condition it already seems ignored…
    So if you please could elaborate…

    #21693
    Long Nguyen
    Moderator

    Hi,

    Could you please switch to the default theme of WordPress (Twenty Twenty) then check the archive page again?

    #21698
    EddyPiV
    Participant

    I have done that, but still the view seems ignored: all posts, pages and cpt’s for this value of the taxonomy are shown, and the initial text “This is the archive view” does not appear.

    #21704
    Long Nguyen
    Moderator

    Hi,

    This problem is so weird, please follow this guide to know how to create the staging site https://www.wpbeginner.com/wp-tutorials/how-to-create-staging-environment-for-a-wordpress-site/.

    Then share the credentials (Admin site and FTP account) via this form https://metabox.io/contact/. I will check it out.

    #21749
    Long Nguyen
    Moderator

    Hi,

    Because there are two views that apply the location for Archive so it does not work properly, see https://share.getcloudapp.com/xQuLJGzD.

    I’ve moved to trash all views and keep one view Nieuwsarchief Breukelen, paste the view shortcode to the page Breukelen then it works as well https://single2.stjandedoper-vechtenvenen.nl/breukelen/.

    #21790
    EddyPiV
    Participant

    Hi Long,

    There is now 1 view of a Custom Type. As the coding for custom type is harder for me to understand/specify, I prefer to use an Archive Type.

    Your comment on various views of Archive Type causing problems confuses me. It’s a bit as I mentioned earlier: I don’t understand the relation between the Archive Location settings and the url it relates to.

    E.g. I need different archive-views for ../location/amsterdam/?post_type=post and ../location/amsterdam/?post_type=event, and for ../location/rotterdam/?post_type=post
    How to define that in the Archive Location settings?

    My problem was that my View seemed to be ignored, perhaps because my Archive Location settings were incorrect.

    #21804
    Long Nguyen
    Moderator

    Hi,

    WordPress itself does not support to filter the post type of the archive taxonomy in the URL like:

    /location/amsterdam/?post_type=post
    /location/amsterdam/?post_type=event

    This is a rarely case when you use one taxonomy for multiple post types so you have to use the code to show the specific post type of the taxonomy.

    You can create another view and set the post type with the code:

    • page
      {% set args = { post_type: 'page', posts_per_page: 5, tax_query: [ { taxonomy: 'geloofsgemeenschap', field: 'slug', terms: 'ggbreukelen' } ] } %}
    • post
      {% set args = { post_type: 'post', posts_per_page: 5, tax_query: [ { taxonomy: 'geloofsgemeenschap', field: 'slug', terms: 'ggbreukelen' } ] } %}

    See my screen record https://www.loom.com/share/9b0b39943f5f4377bf2fc16765706b33.

    #21807
    EddyPiV
    Participant

    That I understand, and I did that before. But I got stuck on the coding, as I didn’t manage to get the post link and the featured image of the post. That’s what I meant when I said that the coding is more difficult for me in this approach.

    So perhaps you can help me with the correct code for getting the post link and the post featured image?

Viewing 10 replies - 11 through 20 (of 26 total)
  • You must be logged in to reply to this topic.