• Resolved benkerve

    (@benkerve)


    Hi there,

    I’m running a WP multisite (v6.3.2) with the latest AIOSEO version (4.5) however on a custom post type single, aioseo_description isn’t being called but aioseo_title and aioseo_keywords are. The meta hooks pull in some data from another childsite (hence the switch_to_blog() being called). All the 3 hooks happen one after the other (in functions.php) in the order of aioseo_title, aioseo_description, aioseo_keywords. I’ve tried commenting out the other hooks, but no avail.

    Snippet of code for aioseo_description I’m using

    add_filter('aioseo_description', function ($description) {
        if (is_singular('venues')) {
          switch_to_blog(get_multisite_id('smart_venues'));
          $seo_description = get_post_meta(get_the_ID(), '_aioseo_description', true);
          restore_current_blog();
    
          return !empty($seo_description) ? $seo_description : $description;
        }
    
        return $description;
    });

    aioseo_title and aioseo_keywords code snippets are exactly the same, they just look at a different get_post_meta field.

    This code works fine elsewhere on other pages, (ie. a normal page etc), its just not being called when on a custom post type. Any thoughts?

    • This topic was modified 1 year ago by benkerve.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support J Burns

    (@subiewrx)

    Hi @benkerve,

    Thanks for reaching out.

    Could you please describe in detail what you’re trying to do and what the outcome should be which will help us troubleshoot the code or create a filter for that process.

    Thanks!

    Thread Starter benkerve

    (@benkerve)

    Hi there,

    In a nut shell we have two child sites, child site one has a custom post type called ‘venues’, which you can view on this child site by (for example) the URL structure /venues/my-house (example), everything is fine, meta data is all fine, data for the CPT shows etc. No issues. However we also need to show this data on child site two with the same URL structure. We have all the necessary code built to do this, everything here works fine however the <head> meta data wasn’t pulling in, so to get around this we implement the aioseo_description, title, keywords hook to bring in this content.

    This also works when viewing a ‘venue’ on child site, aioseo_keywords and aioseo_title hooks are bing picked up/run and bringing in the required data which is populating the <head> meta data etc. But, aioseo_description isn’t being picked up, the hook isn’t running (or being activated etc – however best describes it).

    I’ve tried using the older hook aioseop_description but this I believe is deprecated.

    I’m just wondering if you’ve heard of the scenario where one of these hooks just doesn’t get called, if I’m missing something from the hook (priorities etc?).

    Hope this helps.

    Plugin Author arnaudbroes

    (@arnaudbroes)

    Hey @benkerve,

    If you don’t mind, it would be best for you to reach out to us via our Basic Question form on our website so we can get some details from you and take a look ourselves.

    The code that determines our title/description is quite extensive and complex as it needs to handle dozens of scenarios so it will be a pain to troubleshoot this here.

    But once I can take a look, it should be pretty trivial for me to find the issue since I wrote the code myself.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘aioseo_description hook not being called but aioseo_title or aioseo_keywords is’ is closed to new replies.