How to Solve MPG Tags that are Not Parsed?

πŸ“ Note: Starting with version 3.3.9, this behavior is included by default.

The MPG-generated pages use shortcodes to display different information according to the URL, replacing those with data from the source file.

Some plugins may affect these tags, so some elements, like title or description, don't parse them, even if they're added to the page template.

This article has prepared an example using the Squirrly SEO plugin. Opening one of the MPG-generated URLs and the Inspect tool, we discovered that the tags weren't parsed, even if they appeared right on the website:

To  solve this, we have created a filter where you can replace shortcodes according to your use. Copy it and paste it into the plugin file.

add_filter(
    'sq_description',
    function( $description ) use ( $project_id ) {
        if ( false !== strpos( $description, '{{mpg_' ) ) {
            $description = MPG_CoreModel::mpg_shortcode_replacer( $description, $project_id );
        };
        return $description;
    },
    99
);

πŸ’‘Result 

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us