I used some do_shortcode features to work shortcode in put up title and outline. however i’m unable to make use of shortcode in notification put up title or sharing preview title. Right here you may see my pattern posts.
I wish to add automated date in my WordPress posts and posts title. I used Following codes to including present date in WordPress posts.
add_filter( 'widget_text', 'shortcode_unautop');
add_filter( 'widget_text', 'do_shortcode');
add_filter( 'comment_text', 'shortcode_unautop');
add_filter( 'comment_text', 'do_shortcode' );
add_filter( 'the_excerpt', 'shortcode_unautop');
add_filter( 'the_excerpt', 'do_shortcode');
add_filter( 'term_description', 'shortcode_unautop');
add_filter( 'term_description', 'do_shortcode' );
add_filter( 'wpseo_title', 'do_shortcode' ); // activate shortcode in Yoast Title
add_filter( 'wpseo_metadesc', 'do_shortcode' ); // activate shortcode in Yoast Meta Description
add_filter( 'the_title', 'do_shortcode' ); // activate shortcode in WP Title
add_shortcode( 'current_date', 'mth_footer_date2' );
operate mth_footer_date2() {
ob_start();
echo date("l, jS F Y");
return ob_get_clean();
}
Above code is working positive.. however I unable to see date in Sharing preview or Notification Title. Kindly present resolution.
On my competitor’s web site, I seen that in addition they including present date utilizing shortcode. They use one other code to completed this. on these web site, date showing in each sharing preview and notifications. However, once I used that, I getting some errors. Right here is that code.
operate wpb_date_today($atts, $content material = null) {
extract( shortcode_atts( array(
'format' => ''
), $atts ) );
if ($atts['format'] == '') {
$date_time .= date(get_option('date_format'));
} else {
$date_time .= date($atts['format']);
}
return $date_time;
}
add_shortcode('date-today','wpb_date_today');
They use [date-today]
to signify present date all over the place.