Home › Forums › MapPress Support › Show only current categories
- This topic has 3 replies, 2 voices, and was last updated 13 years, 2 months ago by
Chris.
-
AuthorPosts
-
May 19, 2013 at 4:01 am #12597
Hey,
first of all I want to say “thank you for the wonderful plugin” and “Sorry, for my english, is not my narrative language”!
So, to my question. I have a travel blog and my posts are in categories (like italy, germany, france, …).
I use mappress as a widget in my sidebar.
If I do “current post” I see on my post “Napoli” (category: Italy) only a map with Napoli.
If I do “all post” I see on my post “Napoli” (category: Italy) a map with Napoli and all other posts (from all categories).What i want:
I want that mappress in sidebar shows all posts FROM selectec category. So if I read my post “Napoli” (category: italy) the map also shall show all other posts in “italy” (for example, Rome, Milan, …).
I think it goes about “query”, but I do not understand how I can realise that … please help!kind regards, globesi!
May 19, 2013 at 5:36 am #12598Hi,
There some examples in the documentation, do they work for you?
For example, 5 posts from category ‘mycat’:
posts_per_page=5&category_name=mycat
Or ALL posts:
posts_per_page=-1&category_name=mycat
May 19, 2013 at 6:51 am #12599Dear Chris,
thank you for your answer. But I think you do not understand me.
I know how I can show some posts from a category, BUT I do not know how I can make, that it goes automatic (I describe it already, but okay):
I want that:
If you read post “Napoli”, the map in sidebar shows all posts in category “italy”;
If you read post “Rome”, the map in sidebar shows all posts in category “italy”;
If you read post “Milan”, the map in sidebar shows all posts in category “italy”;
BUT if you read post “Paris”, the map in sidebar shows all posts in category “france”.SO I need that it knows automatic which category has the post and shows the right map.
I do not know how I can it explain in other ways…
May 31, 2013 at 5:26 am #12724Hi,
I haven’t heard back from you so I assume the code is working? For anyone else who needs this, here’s the code to pick up the category from the current post:
<?php $cats = get_the_category(); if (isset($cats[0]) && $cats[0]->slug != 'uncategorized') { $cat = $cats[0]->cat_ID; $query = "posts_per_page=-1&cat=$cat"; $shortcode = '[mashup query="' . $query . '" poilist="true"]'; echo do_shortcode($shortcode); } ?> -
AuthorPosts
- You must be logged in to reply to this topic.
