
-
AuthorPosts
-
June 20, 2025 at 7:34 pm #1485733
Greetings, I’m wanting to change the “Read More” text (on the link button) for select blog categories. Using the support forum I have tried adding the following code to my child theme functions.php file:
Begin Code:
function avf_modify_standard_post_content( $current_post ) {
if ( $current_post[‘post_format’] === ‘standard’ ) {
$categories = get_the_category( $current_post[‘ID’] );
$category_names = wp_list_pluck( $categories, ‘name’ );if ( in_array( ‘Dharma Talks’, $category_names ) ) {
$read_more_text = __( ‘Listen/Read More’, ‘avia_framework’ );
} elseif ( in_array( ‘Music Recordings’, $category_names ) ) {
$read_more_text = __( ‘Listen to this’, ‘avia_framework’ );
} else {
$read_more_text = __( ‘Read more’, ‘avia_framework’ );
}$current_post[‘content’] = $current_post[‘content’] .
‘<div class=”read-more-link”>‘ .
$read_more_text .
‘<span class=”more-link-arrow”></span></div>’;
}return $current_post;
}
add_filter( ‘post-format-standard’, ‘avf_modify_standard_post_content’ );
End Code
This actually works, however, the result is on each blog post I now have two button links: the first is the original Read more and the second is one of the above. So two button links. How can I get this to function correctly.-
This topic was modified 3 weeks, 2 days ago by
ajaxkls.
June 21, 2025 at 3:19 pm #1485759Hey ajaxkls,
Could you add a admin login so we can examine, your snippet above is not in a “code” clip so we can’t examine it fully and our test site doesn’t have the same categories so it is hard to reproduce.Best regards,
MikeJune 21, 2025 at 4:48 pm #1485762This reply has been marked as private.June 22, 2025 at 11:57 pm #1485779Can you help please?
June 23, 2025 at 8:53 am #1485781Hi,
Thank you for the info.
You may need to manually remove this line from the includes/loop-index.php file, around line 151.
$current_post['content'] = $blog_content == 'content' ? get_the_content( __( 'Read more', 'avia_framework' ) . $more_link_arrow ) : get_the_excerpt(); $current_post['content'] = $blog_content == 'excerpt_read_more' ? $current_post['content'] . ' <div class="read-more-link"><a href="' . get_permalink() . '" class="more-link">' . __( 'Read more', 'avia_framework' ) . $more_link_arrow . '</a></div> ' : $current_post['content']; $current_post['before_content'] = '';
To override the template, you can create a copy of /includes/loop-index.php in your child theme folder.
Another option is to edit the filter and ensure that the $current_post[‘content’] is blank before appending the new read more link.
$current_post['content'] = "";
Best regards,
IsmaelJune 23, 2025 at 3:21 pm #1485806Thank you. I copied the entire /includes/ folder to the child theme and removed the line from the includes/loop-index.php file. It caused the entire blog not to load.
On the another option can you tell me exactly where to edit the filter and add the line: $current_post[‘content’] = “”; Is it in the functions.php file?
Kurt
June 24, 2025 at 6:51 am #1485822Hi,
On the another option can you tell me exactly where to edit the filter and add the line: $current_post[‘content’] = “”;
Try to replace the whole post-format-standard filter with this:
function avf_modify_standard_post_content( $current_post ) { if ( $current_post['post_format'] === 'standard' ) { global $avia_config; $blog_content = ! empty( $avia_config['blog_content'] ) ? $avia_config['blog_content'] : 'content'; $more_link_arrow = '<span class="more-link-arrow"></span>'; $categories = get_the_category( $current_post['ID'] ); $category_names = wp_list_pluck( $categories, 'name' ); if ( in_array( 'Dharma Talks', $category_names ) ) { $read_more_text = __( 'Listen/Read More', 'avia_framework' ); } elseif ( in_array( 'Music Recordings', $category_names ) ) { $read_more_text = __( 'Listen to this', 'avia_framework' ); } else { $read_more_text = __( 'Read more', 'avia_framework' ); } $current_post['before_content'] = ''; if ( $blog_content == 'content' ) { $current_post['content'] = get_the_content( $read_more_text . $more_link_arrow ); } else { $current_post['content'] = get_the_excerpt(); } if ( $blog_content === 'excerpt_read_more' ) { $current_post['content'] .= ' <div class="read-more-link"><a href="' . get_permalink() . '" class="more-link">' . esc_html( $read_more_text ) . $more_link_arrow . '</a></div> '; } } return $current_post; } add_filter( 'post-format-standard', 'avf_modify_standard_post_content' );
This block resets the post content to blank, then re-adds the post content or excerpt.
$current_post['before_content'] = ''; if ( $blog_content == 'content' ) { $current_post['content'] = get_the_content( $read_more_text . $more_link_arrow ); } else { $current_post['content'] = get_the_excerpt(); }
Best regards,
IsmaelJune 25, 2025 at 1:51 am #1485863Excellent, thanks for your help.
June 25, 2025 at 6:17 am #1485869 -
This topic was modified 3 weeks, 2 days ago by
-
AuthorPosts
- The topic ‘Blog Element Excerpt Read More Text Duplication …’ is closed to new replies.