• Resolved tapper101

    (@tapper101)


    Hi,

    I’ve been trying to change the default “… Continued” text/link following an excerpt();.

    This didn’t work: <?php the_excerpt( 'L?s mer', false ); seems like it’s just overridden, it doesn’t matter what I write within the parentheses.

    I’ve also tried changing the text through functions.php, but I’m going to assume Virtue has it’s own function doing this exact thing and that’s why it won’t work.

    The WP codex tells us this:

    If you are using a Child Theme, the above code will not work without modification if the parent theme has its own filters setting its own “more” link. You will need to use the remove_filter() function to remove the parent’s filters for yours to work. The problem is your functions.php file is loaded before the parent’s functions.php, so at the time of your file’s execution, there is no filter to remove yet, and your remove_filter() code will fail without warning.

    The key is to put your remove_filter() code in a function that executes from an action hook that triggers after the parent theme is loaded. The following code is an example of the additional code needed to get the above code to work from a child theme of the parent theme Twenty Eleven. You will need to examine your actual parent theme’s code for the correct parameters in the remove_filter() code, they must exactly match the add_filter() parameters used by the parent.

    Any tips?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter tapper101

    (@tapper101)

    All I need to know is where the function that changes the default wordpress ‘read more’ excerpt link to ‘Continued’ is in the labyrinth of Virtue functions and filters, so I can override it.

    Currently I have my excerpts in Swedish followed by “… Continued”, it looks pretty stupid and since you haven’t added a class to the link I can’t do much about it unless I can find your filter.

    hannah

    (@hannahritner)

    Hi,
    Sorry for the delay! You should be able to translate in the po file. You can use loco translate: https://www.ads-software.com/plugins/loco-translate/
    Let me know if this doesn’t work for you.

    Hannah

    All I need to know is where the function that changes the default wordpress ‘read more’ excerpt link to ‘Continued’ is in the labyrinth of Virtue functions and filters, so I can override it.

    Probably kadence_excerpt_more hooked to the excerpt_more filter action (see cleanup.php).

    Thread Starter tapper101

    (@tapper101)

    Probably kadence_excerpt_more hooked to the excerpt_more filter action (see cleanup.php).

    Thanks, that did it.

    For anyone with the same problem:

    function child_theme_excerpt() {
    	// override parent theme's 'more' text for excerpts
    	remove_filter( 'excerpt_more', 'kadence_excerpt_more' );
    }
    add_action( 'after_setup_theme', 'child_theme_excerpt' );
    
    function new_excerpt_more($more) {
           global $post;
    	return '<a class="moretag" style="text-decoration:none" href="'. get_permalink($post->ID) . '">.. L?s mer</a>';
    }
    add_filter('excerpt_more', 'new_excerpt_more');
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to change excerpt link text (‘Continued’)?’ is closed to new replies.