WordPress.org

Ready to get started?Download WordPress

Forums

All in One SEO Pack
[resolved] Shortcodes in titles (11 posts)

  1. jream
    Member
    Posted 4 months ago #

    Hello!

    Is there any way to allow shortcodes in the page title and descriptions? We are running 300 websites in a multisite environment and need the ability to pull the site name and location into the title and description. We already have a custom plugin where these shortcodes are generated. I just need a way for All in One SEO to allow the shortcode in the page titles and descriptions.

    Thanks for any help you may be able to provide!

    Josh

    https://wordpress.org/plugins/all-in-one-seo-pack/

  2. jream
    Member
    Posted 4 months ago #

    Does anyone have any suggestions for this?

  3. Peter Baylies
    Member
    Plugin Author

    Posted 4 months ago #

    Hi jream,

    Yes, you can filter aioseop_title and aioseop_description like so:

    add_filter( 'aioseop_title', 'do_shortcode' );
    add_filter( 'aioseop_description', 'do_shortcode' );
  4. jream
    Member
    Posted 4 months ago #

    That did it! I'm not sure how that works, but it did the trick. Thank you so much! I've been stuck on this for days. I really appreciate the help!

  5. jream
    Member
    Posted 1 month ago #

    Sorry to open this back up, but I'm noticing that your solution works great for the titles but not the descriptions. I double checked my code and it looks identical to what you indicated.

    Any thoughts?

  6. Peter Baylies
    Member
    Plugin Author

    Posted 1 month ago #

    Hi jream,

    Try this instead and see if it improves matters:

    add_filter( 'aioseop_title', 'do_shortcode' );
    add_filter( 'aioseop_description_override', 'do_shortcode' );
  7. jream
    Member
    Posted 1 month ago #

    My goodness, your support is the best I've ever seen!

    Unfortunately, that didn't help. Again, it's working fine for the title.

    The following is what I have in my page settings for description:

    Contact [ic-dealer-name] for your flooring needs. [ic-dealer-address] [ic-dealer-city] , [ic-dealer-state] [ic-dealer-zip] [ic-dealer-phone]

    But is renders as:

    Contact for your flooring needs. ,

  8. Peter Baylies
    Member
    Plugin Author

    Posted 1 month ago #

    Hi jream,

    The good news is, the fact that the shortcodes aren't showing up in the description means that they are getting found and run. The bad news, of course, is that they aren't working as expected. I don't know what those shortcodes are or how they're coded, but if they depend on custom fields / post meta, then that may be why they aren't working, it could be that the post isn't set up properly when the description is getting output; or it may be due to the page you're on, or something else that's running as well.

  9. jream
    Member
    Posted 1 month ago #

    I created a plugin where enter various data items per site. Here's a sample of how the "dealer name" is coded and registered.

    function ic_getdealername() {
        return get_option('ic_dealer_name');
    }
    add_shortcode('ic-dealer-name', 'ic_getdealername');

    They seem to work everywhere in the content and widgets.

  10. Peter Baylies
    Member
    Plugin Author

    Posted 1 month ago #

    Hi jream,

    I've confirmed this behavior; try checking the box at the bottom of the All in One General Settings that says "Never Shorten Long Descriptions"; click Update Options, and see if that fixes your issue.

  11. jream
    Member
    Posted 1 month ago #

    aaannd... that did the trick! Thanks so much! And again, you guys have the best support known to man!

    Thanks Peter!

Reply

You must log in to post.

About this Plugin

About this Topic

Tags