• vin0

    (@vin0)


    Hi,

    I want to pull the title, metatags from a database using a function. I have written the PHP short code using a plugin and it can bring in the title etc.
    However, when I type the PHP shortcode in the title tag of the page, it is output as it is…. and not the value from the php shortcode.

    The PHP short codes work in the body content of the page, but not in the title and description fields of the page. Please advise if I need to use any other plugin, or tweak from the functions.php for the generatepress child theme.

    I also tried this in the functions.php of child theme, just to test it. However, nothing was output in the title.

    add_filter( 'wp_title', 'filter_pagetitle', 10, 2 );
    function filter_pagetitle() {
    return "myunique title";
    }

    Any help or suggestions is much appreciated! Thanks.

Viewing 1 replies (of 1 total)
  • Theme Author Tom

    (@edge22)

    Hi there,

    What plugin are you using to display the title and description fields? Usually those don’t accept shortcodes, but you would have to check with the plugin developer to be sure.

    Usually, I would just suggest going with a plugin like Yoast SEO for this kind of functionality.

Viewing 1 replies (of 1 total)
  • The topic ‘php short code in Title, Metatags’ is closed to new replies.