META Description in Header
I’m trying to get the META Description to be the Question Description in the header. I’m struggling! 😀
I’ve tried this..
<?php if (is_question()) { ?> <meta name="description" content="<?php ap_post_status_description(ap_question_get_the_ID()); ?>"/> <?php } ?>
…and a few other things without sucess. Any advise?
Thats the code the developer tries to use in the theme header, well something similar without success already.
https://wordpress.org/plugins/add-meta-tags/
My site as example of what you’ll get:Â http://dima.stefantsov.com/qa/
Experimented with this already. It doesn’t play well with yoast.
Yoast SEO looks like a scary all-in-one plugin to me. If you insist on using yoast, you should probably contact it’s developers if it can’t render meta description for anspress. Add Meta Tags was recently patched to specifically support AnsPress. I guess Yoast could do the same.
Actually I think add meta tags should have no problems working together with yoast. They solve same issue, but you can disable every other AMT functionality except “auto generate description” and it should work.
Installed and activated to test with only that enabled and it doesn’t output anything!! lol
function get_post_excerpt_by_id( $post_id ) {
global $post;
$post = get_post( $post_id );
setup_postdata( $post );
$the_excerpt = get_the_excerpt();
wp_reset_postdata();
return $the_excerpt;
}
get_post_excerpt_by_id(ap_question_get_the_ID()) something along this lines should work as well.
Why would you try to use ap_post_status_description that renders html into the meta tag anyway?