Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #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 1 day, 23 hours ago by ajaxkls.
    #1485759

    Hey 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,
    Mike

    #1485762
    This reply has been marked as private.
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.