[anspress] Shortcode in some meta

7.92K viewsGeneral
1

I have tried a couple of plugins and all behave the same. The [anspress] shorcode shows instead of some meta description.

Example:

<!-- BEGIN Metadata added by Add-Meta-Tags WordPress plugin -->
<meta name="description" content="[anspress]..." />
<meta property="og:site_name" content="website.com" />
<meta property="og:type" content="article" />
<meta property="og:title" content="Travel Q & A" />
<meta property="og:url" content="http://www.website.com/travel-q-a/" />
<meta property="og:description" content="[anspress]..." />
<meta property="og:locale" content="en_US" />
<meta property="og:updated_time" content="2015-10-27T03:54:42+00:00" />
<meta property="article:published_time" content="2015-05-17T17:38:06+00:00" />
<meta property="article:modified_time" content="2015-10-27T03:54:42+00:00" />
<meta property="article:author" content="http://www.website.com/author/editor/" />
<meta property="article:publisher" content="http://www.website.com/" />
<meta name="dcterms.title" content="Travel Q & A" />
<meta name="dcterms.identifier" content="http://www.website.com/travel-q-a/" />
<meta name="dcterms.creator" content="Editor" />
<meta name="dcterms.created" content="2015-05-17T17:38:06+00:00" />
<meta name="dcterms.available" content="2015-05-17T17:38:06+00:00" />
<meta name="dcterms.modified" content="2015-10-27T03:54:42+00:00" />
<meta name="dcterms.description" content="[anspress]..." />
<meta name="dcterms.language" content="en-US" />
<meta name="dcterms.publisher" content="http://www.website.com/" />
<meta name="dcterms.rights" content="http://www.website.com/" />
<meta name="dcterms.coverage" content="World" />
<meta name="dcterms.type" content="Text" />
<meta name="dcterms.format" content="text/html" />
<link rel="publisher" type="text/html" title="website.com" href="http://www.website.com/" />
<link rel="author" type="text/html" title="Editor" href="http://www.website.com/author/editor/" />
<!-- END Metadata added by Add-Meta-Tags WordPress plugin -->

Any ideas how to solve this ? Thanks

@Dima I see you use the same plugin (WP Add meta tags) ? If so, the next version will have this problem solved (with some fixed regex), as the developer said.

Hello, I am the developer of the Add-Meta-Tags plugin and noticed this discussion while searching the web. I just wanted to let you know that a user discovered a little issue with the algorithm that automatically generates an excerpt, which in some cases could result in shortcodes being re-inserted into the generated excerpt. This seems like one of those cases. This has been fixed in v2.9.6 and should not be a problem any more. I highly recommend upgrading to the latest version. Thanks

The latest version (2.9.6) just removes ANY instance of metas when in Anspress pages. Is that to be considered as normal ?

@Cagliostro: Hello, it possibly depends on the post type (but it’s configurable). This behavior would probably be the case in older plugin releases as well, because the changes in v2.9.6 cannot justify the change of behavior in this particular version. BTW, I’m afraid that these comments are not the right place to discuss this issue. I’d appreciate it if you opened an issue at Github and posted more details there. Thank you in advance.

@gnotaras Εντάξει Γιώργο.

@Cagliostro By default the metadata block is added on the default post/page/attachment post types and to custom post types as returned by this API function:

get_post_types( array(‘public’=>true, ‘_builtin’=>false, ‘show_ui’=>true) );

Maybe that ‘show_ui’ requirement should be removed in a future version. This is already in my todo list, but needs more thought. Your feedback is welcome.

George

Also, the same goes for the Metadata metabox that appears in the post editing screen.

In short, there are two separate utility functions that return the supported post types regarding the addition of the metadata block and the display of the Metadata metabox in the post editing screen.

Hope this helps.

BTW, I’ll investigate what happens with anspress pages more closely soon.

Just wanted to point out that in my tests using AnsPress (from wordpress org) with Add-Meta-Tags I do not notice any unexpected results. For further feedback, please use Github. Thanks!

George, oh, you are an author of excellent Add Meta Tags that I’m using on all my sites!

Yes, AnsPress and AMT don’t go well currently. From the top of my head I can tell: when editing your answer while AMT enabled, edited answer will include AMT-generated content as plaintext. AMT also generates wrong data for anspress: https://anspress.io/questions/question/how-can-i-get-the-meta-description-to-show-in-the-head-of-the-page/?show_answer=8255#answer_8255 here is description with screenshots.

Can’t be sure it’s your fault, not anspress (actually I think it’s anspress code that should be fixed), but there are issues.

Will use your github when I will have time to test everything again and provide good feedback on what should be fixed.
Thanks!

1

With recent changes to Add Meta Tags, it is now completely possible to make it work good with AnsPress. I’m using it, look how good it works: http://dima.stefantsov.com/qa/

add_action('wp', 'd_anspress_amt_fix');
function d_anspress_amt_fix()
{
    // Only make changes when inside AnsPress.
    if (!function_exists('is_anspress') || !is_anspress()) {
        return;
    }


    add_filter('amt_exclude_schemaorg_metadata', '__return_true');
    add_filter('amt_exclude_dublin_core_metadata', '__return_true');

    // Feed AMT with real question-post.
    if (is_question()) {
        add_filter('amt_get_queried_object', function(){ return get_post(get_question_id(), OBJECT); });
    }
}
commented on answer

Dima, I’d like to publicly thank you for the research and contributions about this issue and for the customization sample above, which makes the two plugins work well together.

Also, a thumbs up to Rahul for creating a useful plugin! Keep up the good work!

George

thanks it works greet

-1

I think you are using yost seo, then there is a filter for overriding content meta please check their doc.

No, i’m not using Yoast since it slows me down. I will research this better and let you know.