• Resolved Bartox

    (@bartox)


    Hi,

    I know this topic has been treated several times but I don’t really want to use Poedit because my site isn’t meant to be used by foreign people.

    I just would like to change “Read the post” by something else but I can’t find the function in “content.php” and I don’t really know where it could be located elsewhere.

    Thanks ??
    Bartox

Viewing 8 replies - 1 through 8 (of 8 total)
  • I had this problem too. Cobbling together some previous posts I changed it by adding this to my functions.php file (this changed my ‘Read the Post’ to ‘[More]’:

    function my_tracks_excerpt_read_more_link($output) {
    global $post;
    return $output . “<p>” . __(‘[More]’, ‘tracks’) . “<span class=’screen-reader-text’>” . get_the_title() . “</span></p>”;
    }
    add_filter(‘the_excerpt’, ‘my_tracks_excerpt_read_more_link’, 999);
    remove_filter(‘the_excerpt’, ‘ct_tracks_excerpt_read_more_link’); /* to remove double link*/

    I found my functions.php via:
    Dashboard -> Appearance -> Editor -> functions.php (‘Theme functions’ on list on lefthand side).

    The downside of this from what I read was if you upgrade the theme your functions.php will be overwritten because, if you’re like me, you have no idea how to setup a child theme properly in the wordpress dashboard.

    Theme Author Ben Sibley

    (@bensibley)

    The above function is exactly right. I’m going to repost it here with the code formatting:

    function my_tracks_excerpt_read_more_link($output) {
      global $post;
      return $output . "<p>" . __('[More]', 'tracks') . "<span class='screen-reader-text'>" . get_the_title() . "</span></p>";
    }
    add_filter('the_excerpt', 'my_tracks_excerpt_read_more_link', 999);
    remove_filter('the_excerpt', 'ct_tracks_excerpt_read_more_link’);

    For using a child theme, we have a tutorial here you can follow. And here is a pre-made, empty Tracks child theme (click to download).

    With the function above, the one extra step you need to take is to create an empty file called “functions.php” in your child theme. Then you can add the above function to that file.

    Thank you! That is very helpful. I couldn’t figure out how to upload, or create, a functions.php file via wordpress for the child theme.

    Theme Author Ben Sibley

    (@bensibley)

    You’re welcome ??

    I will include a functions.php file in the child theme’s in the future.

    For creating your own: there isn’t anything special about the functions.php file, it is just the name of the file that matters. You could simply create a file called functions.txt with whatever text editor you have on your computer. Then, change the file extension to “.php”. This will work just fine in the child theme.

    Thread Starter Bartox

    (@bartox)

    Thanks for the help both of you ??

    Thank you!

    hi Ben,

    I installed the child theme, and inserted this

    function my_tracks_excerpt_read_more_link($output) {
    global $post;
    return $output . “<p>” . __(‘[More]’, ‘tracks’) . “<span class=’screen-reader-text’>” . get_the_title() . “</span></p>”;
    }
    add_filter(‘the_excerpt’, ‘my_tracks_excerpt_read_more_link’, 999);
    remove_filter(‘the_excerpt’, ‘ct_tracks_excerpt_read_more_link’);

    and got “white” screen” , edited that out via cpanel file manager, and it’s ok now, but how can i get that function to work on the child theme, php file?

    I know how to change the php file in the parent tracks theme, and that works fine, but i think i’d better use the child theme to protect from future updates.

    Theme Author Ben Sibley

    (@bensibley)

    Make sure you start the functions.php file with an opening php tag: <?php. Just add that code to the very first line of the file and it should fix the white screen.

    Also, that function is actually a bit easier to override now. Here is the new code you can use:

    function ct_tracks_excerpt_read_more_link($output) {
      global $post;
      return $output . "<p>" . __('[More]', 'tracks') . "<span class='screen-reader-text'>" . get_the_title() . "</span></p>";
    }
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Remove or change "Read the post"’ is closed to new replies.