• Resolved kjeft

    (@kjeft)


    I am trying to change the url my ‘read more’ tags are pointing to, using this code on my custom pages:

    <?php global $more;
    $more = 0;
    the_content('<span id="more-text"> Read more...</span>',FALSE,'https://www.google.com'); ?>

    Any ideas why it is not working?

Viewing 4 replies - 1 through 4 (of 4 total)
  • I am just going through the same thing – the documentation is totally bogus. The third parameter is not even passed to the_content in 3.0, and ignored in 2.8 and 2.9 (at least).

    I am working on a fix using the_content_more_link filter, but so far no luck.

    This seems to work on the_content(). I was fighting with the_excerpt() until I figured out that the twentyten theme registers a filter for get_the_excerpt that was sticking a link in with the default text. I guess I will have to override that one, too.

    Stick this function somewhere ahead of the call to the_content().

    <?php
       // Replace the_content more link with a global value, if it exists.
       function mam_content_more_link_filter ($link,$link_text) {
         global $mam_global_fix_this_more_link;
         if ($mam_global_fix_this_more_link) {
           $link = $mam_global_fix_this_more_link;
         }
         return $link;
       }
    add_filter('the_content_more_link','mam_content_more_link_filter',10,2);
    ?>

    Then, define $mam_global_fix_this_more_link and set it to the value you want for the entire link – < a tag and all:

    <?php global $mam_global_fix_this_more_link;
    $mam_global_fix_this_more_link = "<a href='https://nomore.com' >My New Text</a>"; ?>
    <?php the_content( 'Read more ...' ); ?>
    <?php unset($mam_global_fix_this_more_link); ?>

    Be sure to unset the global after the_content so any other loops won’t get that same link.

    Thread Starter kjeft

    (@kjeft)

    Thanks so much, it works perfectly!

    You are welcome!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Change more tag url’ is closed to new replies.