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 6 replies - 21 through 26 (of 26 total)
  • Author
    Replies
  • #21808
    Long Nguyen
    Moderator

    Hi,

    To get the post permalink or featured image URL, you can use the built-in functions of WordPress, get all information of the post base on the ID.
    https://developer.wordpress.org/reference/functions/get_permalink/
    https://developer.wordpress.org/reference/functions/get_the_post_thumbnail_url/

    {% set post_link = mb.get_permalink(post.ID )  %}    
    {% set featured_image_url = mb.get_the_post_thumbnail_url(post.ID, 'medium') %}
    <h3><a href="{{ post_link }}">{{ post.post_title }} </a></h3>
    <img src="{{ featured_image_url }}">{{ post.post_date | date( 'd/m/Y' ) }}<br />
    #21811
    EddyPiV
    Participant

    Thanks Long.
    It works. I have managed to further adjust it to my liking.
    Except for the pagination, that doesn’t work, no paging is shown. Any light on that?

    #21814
    Long Nguyen
    Moderator

    Hi,

    The function get_posts() works perfectly if you are going to use a custom query that doesn’t need pagination. If you want to show the pagination, please use WP_Query via PHP code to show it.

    Please follow the documentation for more information https://developer.wordpress.org/reference/functions/paginate_links/#user-contributed-notes.

    Refer topic: https://metabox.io/support/topic/show-pagination-for-query/

    #21823
    EddyPiV
    Participant

    Hi,

    That’s what I meant when I said that for me the coding is more difficult for Custom views than for the Archive views. In the archive views we have the {{ mb.get_the_posts_navigation() }} function, but that doesn’t work for the custom view.
    I have puzzled many hours to get this figured out for the custom view, but without success. All the time I get “critical error on my website” message.

    Isn’t there any help to get this easier supported for custom view??

    #21830
    Long Nguyen
    Moderator

    Hi,

    I’m not sure about your purpose or benefit when using one taxonomy for multiple post types. In this case, we have to use more PHP code to achieve the goal, where the MB View tool cannot cover. Can you consider to use one taxonomy for one post type? For easier to show posts by taxonomy and use the archive page.

    #21842
    EddyPiV
    Participant

    Hi,

    To me is doesn’t make sense to define multiple taxonomies for actually the same thing, with all having the same items.

    Anyway, I tried your approach and it indeed showed the pagination link, but also in case it shouldn’t.
    For one type I had only 3 instances, these were shown, plus the Next link.
    Pressing that next link told me that there were 14 posts, and the last 4 were shown. So it looks like it thought it had shown 10 occurrences on the previous page…

    Whatever, it introduced new questions, and I have the feeling that I take 2 steps back again, while I am so close.

    My decision is to stay with 1 taxonomy and with your solution for the custom pages based on get-posts, with a larger number of posts to show, and forget the pagination.
    This works, looks nice, and I expect it will be acceptable to the client.

    Thanks a lot for your patience and help.
    Let’s close this thread.

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