Show all POI from one page and a custom post type

Home Forums MapPress Support Show all POI from one page and a custom post type

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #18141
    roamingk
    Participant

    I 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?

    #18142
    Chris
    Keymaster

    There’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-documentation

    #18145
    roamingk
    Participant

    I 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?

    #18147
    Chris
    Keymaster

    Hi, 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-documentation

    #18154
    roamingk
    Participant

    I tried that too..
    [mashup query=“category__in=bar,hotel” width="100%" height="600"]

    But it is bringing up all the categories (beaches, saunas, restaurants)

    #18160
    roamingk
    Participant

    Any idea why all categories are showing up? I checked the categories and they are all separate. no sub categories etc.

    #18162
    Chris
    Keymaster

    I 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.

    #18163
    Chris
    Keymaster

    I 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.

    #18193
    roamingk
    Participant

    I 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?

    #18194
    Chris
    Keymaster

    I 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).

    #18197
    roamingk
    Participant

    ok i sent you log in credentials via the form.

    #18198
    Chris
    Keymaster

    I 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=edit

    And also corrected the original mashup.

    I hope that helps!

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.