Geo Text WordPress Plugin

FAQ

Is the plugin multisite ready?

The plugin will work on a multisite installation, but the settings are set globally for all blogs on the site. So if you have the plugin installed on a multisite installation but not network activated, then any blog owner can change the GeoIP detection method setting the plugin uses on their blog, and it will also affect all the other blogs on the same installation. Similarly, if any blog owner adds / modifies / removes a grouping from the plugin settings, then this will affect all the other blogs on the same installation.

If this is an issue for you, please let me know.

Is this plugin compatible with caching plugins like WP Super Cache and W3 Total Cache?

For compatibility with WordPress Super Cache you need to use either a geo-targeted caching WPSC plugin, such as the Geo Targeted Caching plugin for WP Super Cache, or a partial cache WPSC plugin, such as Dynamic Shortcodes plugin for WP Super Cache.

For compatibility with W3 Total Cache the same is true. For Geo-targeted caching with W3TC, you can use the Dynamic Shortcodes extension for W3 Total Cache. Or for partial caching you can use the Geo Targeted Caching extension for W3 Total Cache.

Each uses a different method of enabling compatibility – Geo Targeted Caching is more efficient but requires you have server based GeoIP detection enabled or the PHP GeoIP extension installed. Dynamic Shortcodes is not as efficient but will work if you are using a WordPress GeoIP detection plugin. For more information on the differences between these methods see Differences between caching methods with Geo targeted content.

Paragraph breaks are removed between blocks enclosed by the shortcodes

Unfortunately this appears to be a problem in the WordPress core, as the shortcodes built-in to WordPress, such as [caption] display the same effect.

When you have content in a post such as

<p>[caption]Some text in a shortcode[/caption]</p>
<p>[caption]Some more text in a different shortcode[/caption]</p>

WordPress will collapse the paragraph tags between the shortcodes, resulting in the following:

<p>Some text in a shortcodeSome more text in a different shortcode</p>

A work-around is to ensure you have a some text between the shortcode(s) and the end of the paragraph, e.g.

<p>[caption]Some text in a shortcode[/caption].</p>
<p>[caption]Some more text in a different shortcode[/caption]</p>

(note the full stop at the end of the first paragraph, outside of the shortcode).

If this bug bothers you, please ask the WordPress developers to fix it as there is nothing I can do about it.

The shortcode doesn’t work in a post title / page title

WordPress doesn’t process shortcodes in the title. If you want it do so, you’ll need to edit the theme you’re using.

In your theme’s functions.php file, add the following:

add_filter('wp_title', 'modify_wp_title', 9);
add_filter('the_title', 'modify_wp_title');
function modify_wp_title($title){
    return do_shortcode($title);
}

What that should do is to make it so that WordPress will now process any shortcodes in the title when either wp_title() or the_title() are called to display the title in your theme.

I tested the above with the twentyfourteen theme and it worked fine. If it doesn’t work, it is likely that your theme is not using wp_title() and the_title() to display the title, but some other method.

You can check the page template (e.g. single.php) to make sure it is using wp_title() function to display the title. If it isn’t then the above fix won’t work. Here’s an example line from the single.php file used in a theme on one of my sites:

<h1 id="post-<?php the_ID(); ?>" itemprop="name"><a href="<?php the_permalink() ?>" rel="bookmark" ><?php the_title(); ?></a></h1>

You can see from the excerpt above the theme file is using the_title() function to display the title between some h1 heading tags. Also check the theme’s header.php, which should be using wp_title() function to set the page’s title. Using the header.php from my theme, it has the following line:

<title><?php wp_title( '' ); ?></title>
Posted on by xoogu, last updated

Leave a Reply