Home › Forums › MapPress Support › Shortcode in category description
- This topic has 4 replies, 2 voices, and was last updated 10 years, 6 months ago by
dreambuilders.
-
AuthorPosts
-
July 9, 2012 at 12:14 pm #9846
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 moreCategory 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?
July 10, 2012 at 6:14 am #9862Hi,
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.
July 10, 2012 at 10:41 am #9872Hi 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.
July 10, 2012 at 11:27 am #9876Hi,
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.
July 24, 2012 at 12:41 am #10034Hi,
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.
-
AuthorPosts
- You must be logged in to reply to this topic.