Support Forum
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.
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.
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/.
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.
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:
{% 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.
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?
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 />
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?
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://support.metabox.io/topic/show-pagination-for-query/
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??
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.
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.