Mushup php current category

Home Forums MapPress Support Mushup php current category

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #12356
    magnaromagna
    Participant

    Hello, I did not find how to configure this: I’d like to show a map of all post under the current category. I mean: if I visit category number 1, I’d like to show a map with all posts. Something like

    [mashup query=”current category”] , but in php

    I see that mappress widget could show map of all posts in the same page of category: is possible to extend this query to all posts of the whole category, not only the post of the page? Hope I explained it
    Thanks

    #12360
    Chris
    Keymaster

    Hi,

    It’s possible but you’ll need some PHP to do this.  You’ll need to get the category first (you can search wordpress.org for solutions to that).  Then run the mashup shortcode.

    I haven’t tested it but for example: this should read the category id from the query variable ‘cat’:

    $category_id = get_query_var('cat');
    $shortcode = '[mashup query="cat=' . $category_id . '&posts_per_page=-1"]';
    echo "Map of shortcode $shortcode" . "<br/>";
    do_shortcode($shortcode);
    #12362
    magnaromagna
    Participant

    Thank you, but not works properly: it take the right category id, but not show the map, only prints this:

    Map of shortcode [mashup query=”cat=98&posts_per_page=-1″]

    #12363
    Chris
    Keymaster

    Hi, try adding ‘echo’ before do_shortcode:

    $category_id = get_query_var('cat'); 
    $shortcode = '[mashup query="cat=' . $category_id . '&posts_per_page=-1"]'; 
    echo "Map of shortcode $shortcode" . "<br/>"; 
    echo do_shortcode($shortcode);
    
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.