Home › Forums › MapPress Support › Show all POI from one page and a custom post type
Tagged: custom posts, mashup
- This topic has 11 replies, 2 voices, and was last updated 4 years, 7 months ago by
Chris.
-
AuthorPosts
-
January 11, 2019 at 2:11 pm #18141
roamingk
ParticipantI have a custom post type “bars” and I have one page with 5 hotels. Is it possible to show in a mash up all the bars in the category and the 5 hotels from the page?
I tried this [mashup query="post_type=bars" query="post__in=19" width="100%" height="600"]
But it only shows the second query? Can they be combined? If so what is the code?
January 11, 2019 at 2:18 pm #18142Chris
KeymasterThere’s no way to pass ‘OR’ queries like this through the shortcode.
However, you could assign all the relevant posts to categories rather than using post type (e.g., category ‘bars’ and ‘hotels’), then query by all the necessary categories (you can separate categories by commas).
Or, group them under a specific separate taxonomy just for the purpose of combining them, such as a ‘map1’ tag.
There are some example queries here:
http://mappresspro.com/mappress-documentationJanuary 15, 2019 at 7:50 am #18145roamingk
ParticipantI changed the hotel page to a post and assigned it a category hotel.
I then created the mash-up[mashup query="category__and=bar,hotel&posts_per_page=-1" width="100%" height="600"]
But it is showing all of the actual categories, not just the two I specify? Have I made an error in the shortcode?
January 15, 2019 at 7:52 am #18147Chris
KeymasterHi, that query only finds posts with both categories. I think you want posts in either category, which would be:
“category__in=bar,hotel”
There are some additional examples in the documentation:
http://mappresspro.com/mappress-documentationJanuary 21, 2019 at 6:29 am #18154roamingk
ParticipantI tried that too..
[mashup query=“category__in=bar,hotel” width="100%" height="600"]But it is bringing up all the categories (beaches, saunas, restaurants)
January 21, 2019 at 6:29 am #18160roamingk
ParticipantAny idea why all categories are showing up? I checked the categories and they are all separate. no sub categories etc.
January 21, 2019 at 6:30 am #18162Chris
KeymasterI haven’t had a chance to look at this over the weekend, but I haven’t forgotten about you. I’ll test it on my own system and let you know if I can replicate the problem.
January 21, 2019 at 6:51 am #18163Chris
KeymasterI just tested this and the query seems to work for me. But I think I see the problem: the various WordPress query selectors work either on names (slugs) or IDs. If the wrong type of argument is provided, WordPress will ignore that part of the query and show all results.
In the example above, ‘category__in’ uses IDs, so it would need to be something like ‘category__in=1,5,7’. For names, use ‘category_name’ instead, e.g. ‘category_name=red,blue,green’.
There are some examples of the various selectors in the docs, or the WordPress codex page.
Be careful to also match the underscores – some selectors use two and some use one.
February 5, 2019 at 2:59 am #18193roamingk
ParticipantI tried both category id and name and it still seems to bring up all.
[mashup query=“category__in=12,22” width="100%" height="600"]Am using Easy Custom Post Types plugin to create the custom posts, perhaps this might be causing an issue?
February 5, 2019 at 3:01 am #18194Chris
KeymasterI don’t know about the other plugin. What happens if you set up a standard post category and assign a few posts to it. Does the query work then?
If not, please use the contact form to send a login and I’ll try to trace the issue for you. It’s working on my test blogs so I’ll need to see it on yours (preferably a test system, if you have one).
February 5, 2019 at 9:19 am #18197roamingk
Participantok i sent you log in credentials via the form.
February 5, 2019 at 9:23 am #18198Chris
KeymasterI looked at the site and I think the problem is the quotes in the shortcode. It contained angled quotes, which are normally used by visual editors. WordPress ignores this type of quote when processing shortcode arguments.
What you need are straight quotes, which is what are input using the normal WordPress editor (you can check by using the ‘text’ tab instead of ‘visual’):
I created a private post here that shows the different quote types:
https://www.gaytorremolinos4u.com/wp-admin/post.php?post=928&action=editAnd also corrected the original mashup.
I hope that helps!
-
AuthorPosts
- You must be logged in to reply to this topic.