Shortcode in category description

Home Forums MapPress Support Shortcode in category description

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #9846
    dreambuilders
    Participant

    Hi,
    The following code works fine in a post/page but in category description it doesn’t:

    [mashup show=query show_query=category__in=5&posts_per_page=-1]

    Then it returns:

    <script type=”text/javascript”>

    /* <![CDATA[ */var mapdata = {“mapid”:null,”width”:425,”height”:350,”zoom”:null,”center”:{“lat”:0,”lng”:0},”mapTypeId”:”roadmap”,”title”:”Untitled”,”metaKey”:null,”pois”:[{“point”:{“lat”:58.8997257325,”lng”:17.9512120369},”title”:
    … and a lot more

    Category description is loadad by:
    <?php echo category_description(); ?>

    This lines are added to functions.php:
    add_filter( ‘term_description’, ‘shortcode_unautop’);
    add_filter( ‘term_description’, ‘do_shortcode’ );

    Any ideas how to get it work?

    #9862
    Chris
    Keymaster

    Hi,

    If I understood, you want to output a map automatically when printing a category description?

    I’m guessing the [mashup] shortcode is actually part of the description then?  For example you have a category 123 with description “My category [mashup]”?

    I would suggest trying this using the 2.38.3 beta version.  It outputs the scripts in the footer rather than immediately, so it might work better in this case.

    #9872
    dreambuilders
    Participant

    Hi again,

    I would like to add mashups in the category description. To do this instead of adding it in the category theme file I can chose in which categories there should be a mashup.

    When I upgraded to 2.38.3 beta I got the following error:

    Fatal error: ob_start() [<a href=’ref.outcontrol’>ref.outcontrol</a>]: Cannot use output buffering in output buffering display handlers in /home/jakob10/domains/segla.nu/public_html/wp-content/plugins/mappress-google-maps-for-wordpress/pro/mappress_pro.php on line 372

    It still works well when using it in a page.

    #9876
    Chris
    Keymaster

    Hi,

    Ok, I’ll see if I can replicate the error.

    But I would also suggest you try another approach.  I think a little code in the theme file would work better than trying to embed shortcodes into the category descriptions.

    For example: you could indicate that a category needs a map by using “*” as the first character in the category name.  In the theme file if you see an “*” in the name then output the map for that category using do_shortcode().

    This would also help to determine if there’s a general issue or if it was just a problem when embedding shortcodes in the descriptions.

    #10034
    dreambuilders
    Participant

    Hi,

    I put this code in the category template file and it works fine:

    <?php echo do_shortcode(‘[mashup width=”495″ height=”250″]’); ?>

     

    But now I show a map in the categories where I have no posts with maps. Couldn’t you add some type of short code to not show the map if there are no spots on it.

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