Show only current categories

Home Forums MapPress Support Show only current categories

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #12597
    globesi
    Participant

      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!

      #12598
      Chris
      Keymaster

        Hi,

        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

        #12599
        globesi
        Participant

          Dear 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…

          #12724
          Chris
          Keymaster

            Hi,

            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 != &#039;uncategorized&#039;) {
                    $cat = $cats[0]->cat_ID;
                    $query = "posts_per_page=-1&cat=$cat";
                    $shortcode = &#039;[mashup query="&#039; . $query . &#039;" poilist="true"]&#039;;
                    echo do_shortcode($shortcode);
            }
            ?>
          Viewing 4 posts - 1 through 4 (of 4 total)
          • You must be logged in to reply to this topic.