WordPress.org

Ready to get started?Download WordPress

Forums

Basic Google Maps Placemarks
[resolved] error when adding do shortcode to function.php (7 posts)

  1. andy3000
    Member
    Posted 1 year ago #

    I have added the following to functions.php
    I am trying to place the map on the front page of a blog where Reading Settings is set to front page shows latest posts
    I get the following error:
    Parse error: syntax error, unexpected T_VARIABLE in /home/content/40/9512840/html/wp-content/themes/wp-creativix/functions.php on line 16
    Wasn't sure if return_true should be proceeded with one _ or two but either way i get the error.

    function bgmpShortcodeCalled()
    {
    	global $post;
    
    	$shortcodePageSlugs = array(
    		'home'
    	);
    
    	if( $post )
    		if( in_array( $post->post_name, $shortcodePageSlugs ) )
    			add_filter( 'bgmp_map-shortcode-called', '__return_true' );
    }
    add_action( 'wp', 'bgmpShortcodeCalled' );

    http://wordpress.org/extend/plugins/basic-google-maps-placemarks/

  2. Ian Dunn
    Member
    Plugin Author

    Posted 1 year ago #

    Did you recently upgrade to version 1.8? I accidentally overwrote the tags/1.8 directory with trunk about 30 minutes ago, but it's fixed now. If you reinstall 1.8 that will fix it.

    If not, could you copy the entire functions.php file to pastebin.com and post a link here?

  3. andy3000
    Member
    Posted 1 year ago #

    I had not upgraded but I did and I corrected an error in the php file but now I'm getting

    Basic Google Maps Placemarks error: JavaScript and/or CSS files aren't loaded. If you're using do_shortcode() you need to add a filter to your theme first. See the FAQ for details.
    even though I added the filter code above.

  4. andy3000
    Member
    Posted 1 year ago #

    Here is the functions file in pastebin. Note that error has changed to the one in the post directly above this. (Its telling me I need to ad the filter)

  5. Ian Dunn
    Member
    Plugin Author

    Posted 1 year ago #

    I think the home page might be a special case; I'm not sure the page slug works for a page that's assigned as the home page. Try adding code inside the bgmpShortcodeCalled() function, at the bottom.

    if( is_front_page() || is_home() )
    		add_filter( 'bgmp_map-shortcode-called', '__return_true' );
  6. andy3000
    Member
    Posted 1 year ago #

    That code works. As an obvious place to use the map plugin is probably on the front page that shows latest posts you might want to add that code to the installation directions. Thanks!

  7. Ian Dunn
    Member
    Plugin Author

    Posted 1 year ago #

    Good point, I'll update that in the next release.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic