-
AuthorPosts
-
April 15, 2022 at 4:45 pm #1348516
Hi,
I need to completely remove any reference to itemprop datePublished and dateModified from the theme.
I’ve tried with this code:function avia_markup_helper_attributes_modified($attributes, $args) { if (check_active_remove_frontend_date()) { if ($args['context'] == 'entry_time') { unset($attributes['itemprop']); unset($attributes['datetime']); } if($args['context'] == 'blog_date_modified') { unset($attributes['itemprop']); unset($attributes['itemtype']); } } return $attributes; } add_filter('avf_markup_helper_attributes', 'avia_markup_helper_attributes_modified', 10, 2);
It partially works, and now in page html code I have this for datePublished and dateModified :
<span class="av-structured-data">2022-04-01 17:17:13</span> <span class="av-structured-data">2022-04-14 09:55:33</span>
Is there a way to completely remove these span? I don’t want any date reference in the theme.
Thank you.
April 16, 2022 at 8:52 pm #1348577Hey WPStyling2020,
Please try editing the schema code in /enfold/includes/helper-markup.php by removing lines 425-433, in version 4.9.2.1:if( ! in_array( 'date', $exclude ) ) { $output .= "<span class='av-structured-data' {$entry_time_markup}>{$post->post_date}</span>"; } if( ! in_array( 'date_modified', $exclude ) ) { $output .= "<span class='av-structured-data' {$date_markup}>{$post->post_modified}</span>"; }
then add this file to your child theme in the directory /includes/
then add this function to the top of your child theme functions.php:require_once( 'includes/helper-markup.php' );
in my test this worked:
Best regards,
MikeApril 19, 2022 at 3:04 pm #1348810Thank you, it works.
Is there a way to directly modify helper-markup output trough a specific hook ( to avoid helper-markup.php copy in child theme folder) ?April 20, 2022 at 12:28 pm #1348927Hi,
Glad to hear that this solution works for you, I will ask the rest of the team if they know of a filter solution, thank you for your patience.Best regards,
MikeApril 20, 2022 at 1:53 pm #1348934Hi,
The Dev Team will add a filter to the next release, you can apply this now to your version by first removing the child theme file above and the function for it in the child theme functions.php and adding this line to parent theme /enfold/includes/helper-markup.php
on line 348$exclude = apply_filters( 'avf_blog_entry_markup_helper_exclude', $exclude, $id );
and then add this filter to your child theme:function custom_avf_blog_entry_markup_helper_exclude( array $exclude = array(), $id = 0 ) { $exclude = array_merge( $exclude, array( 'date', 'date_modified' ) ); return $exclude; } add_filter( 'avf_blog_entry_markup_helper_exclude', 'custom_avf_blog_entry_markup_helper_exclude', 10, 2 );
Best regards,
MikeApril 22, 2022 at 4:46 pm #1349156Great!
Thank you for your support.
Looking forward for the next theme release.- This reply was modified 2 years, 6 months ago by WPStyling2020.
April 22, 2022 at 4:50 pm #1349158Hi,
Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
- The topic ‘How to remove span.av-structured-data for specific itemprop’ is closed to new replies.