• Resolved Gillian

    (@ridgididgi)


    Hi Ian

    I am trying to include a shortcode in the pop-up info box for the placemark (which gets its data from the custom post) but the shortcode operation is ignored and the info box just outputs the shortcode text eg [this is my shortcode].

    Is there support for shortcode usage in the BGMP custom post? If not, is it planned, or might there be a workaround?

    Thanks in advance.

    Ridgididgi

    https://www.ads-software.com/extend/plugins/basic-google-maps-placemarks/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Ian Dunn

    (@iandunn)

    The plugin doesn’t support that by default, but it might not be too hard to add it. I’ll look into it for one of the upcoming versions.

    In the meantime, you could try adding some code like this to your theme’s function.php file

    function bgmp_parse_shortcodes( $placemarks )
    {
    	for( $i = 0; $i < count( $placemarks ); $i++ )
    		$placemarks[ $i ][ 'details' ] = do_shortcode( $placemarks[ $i ][ 'details' ] );
    }
    add_filter( 'bgmp_get-placemarks-return', 'bgmp_parse_shortcodes' );
    Thread Starter Gillian

    (@ridgididgi)

    Hi Ian

    Many thanks for the code ??

    I created a child theme and included the code in the child theme’s functions.php file, but unfortunately all my placemarks disappeared ??

    Help! I have temporarily disabled the child theme’s functions.php file to get my placemarks back in the meantime.

    Ridgididgi

    Plugin Author Ian Dunn

    (@iandunn)

    Er, I forgot to return the $placemarks variable. Try this…

    function bgmp_parse_shortcodes( $placemarks )
    {
    	for( $i = 0; $i < count( $placemarks ); $i++ )
    		$placemarks[ $i ][ 'details' ] = do_shortcode( $placemarks[ $i ][ 'details' ] );
    
    	return $placemarks;
    }
    add_filter( 'bgmp_get-placemarks-return', 'bgmp_parse_shortcodes' );
    Thread Starter Gillian

    (@ridgididgi)

    Hi Ian

    That is supercalifragilisticexpialidocious ??

    It’s all working now, many thanks. It would be great to have the ability to include shortcodes in the custom post in an upcoming version of your plug-in.

    For your info, the shortcode I wanted to include pulls data from the database so that a number (and its related percentage) is automatically updated in the info box as new entries are recorded in the database. The shortcode works fine in a page, but returns a zero (and divide by zero error for the percentage operation) in the placemark post. I got around that difficulty by using the Shortcode Exec PHP plug-in and creating two more shortcodes (one for the count and one for the percent) and then using the “echo do_shortcode” command to call up the respective original shortcodes.

    I’m sure my convoluted solution isn’t optimal, but at least it works so I’m happy ??

    Many thanks again for your great support and a belated Merry Christmas!

    Ridgididgi

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Basic Google Maps Placemarks] Including Shortcodes in Info Box’ is closed to new replies.