Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1166312
    pcnordhaug
    Participant

    Hi there!

    I have before customized the Read More tekst. Made it a button and changed the text to my language. Found this code in here and worked out perfect;

    // Remove the ... from excerpt and change the text
    
    function x_excerpt_string( $more ) {
      
      $stack = x_get_stack();
    
      if ( $stack == 'integrity' ) {
        return ' ... <div><a href="' . get_permalink() . '" class="more-link">' . __( 'Les mer &rarr;', '__x__' ) . '</a></div>';
      } else if ( $stack == 'renew' ) {
        return ' ... <a href="' . get_permalink() . '" class="more-link">' . __( 'Les mer &rarr;', '__x__' ) . '</a>';
      } else if ( $stack == 'icon' ) {
        return ' ...';
      }
    
    }
    
    add_filter( 'excerpt_more', 'x_excerpt_string' );

    I now tried to add some custome text to the excerpt an them this button disappeared.

    Found this code in here to fix this;

    // Adding Excerpt to Posts 
    function excerpt_read_more_link($output) {
       global $post;
       return $output . '<a href="'. get_permalink($post->ID) . '"> Read More</a>';
    }
    add_filter('the_excerpt', 'excerpt_read_more_link');

    The only thing this did was to put a “Read more” on the bottom.

    I would like to have the same botton here too. But how?

    #1166321
    pcnordhaug
    Participant
    This reply has been marked as private.
    #1166644
    Jade
    Moderator

    Hi there,

    Please try this code:

    // Adding Excerpt to Posts 
    function excerpt_read_more_link($output) {
       global $post;
       return $output . '<a href="'. get_permalink($post->ID) . '" class="more-link"> Read More</a>';
    }
    add_filter('the_excerpt', 'excerpt_read_more_link');

    Hope this helps.

    #1167585
    pcnordhaug
    Participant

    Thanx – that helped! Only problem now is that if i dont want to hace custome excerpts on some posts the Read More Button comes in twice. Is there a way to solve this?

    #1167712
    Paul R
    Moderator

    Hi,

    Please remove the code in your functions.php and add your read more link together with your custom excerpt.

    eg. http://screencast.com/t/WxweLkxBRMKf

    #1170788
    pcnordhaug
    Participant

    Sweet! Thanx a lot! 🙂

    #1170814
    Rue Nel
    Moderator

    You’re welcome!
    Thanks for letting us know that it has worked for you.

    #1200105
    pcnordhaug
    Participant

    This issue above was solved with this code in functions.php

    function excerpt_read_more_link($output) {
       global $post;
       return $output . '<a href="'. get_permalink($post->ID) . '" class="more-link"> Les mer &rarr;</a>';
    }
    add_filter('the_excerpt', 'excerpt_read_more_link');

    There is no “read-more-link” placed together with the custom excerpt. Just the text.

    This workes great. But if you do a search for a word both the blog posts and portfolio post appear. The blog posts works with just one “read-more”-button because of the code obove – but not the portfolio post. They still have two of them. Is there a way to remove one of them with a similar code?

    #1200117
    Christopher
    Moderator

    Hi there,

    All pages except home page shows under construction page.
    Please check.

    Thanks.

    #1215324
    pcnordhaug
    Participant
    This reply has been marked as private.
    #1215677
    Rupok
    Member

    Hi there,

    So this problem is for the search result page only? In that case you can add this under Custom > CSS in the Customizer.

    .search-results .excerpt div > .more-link {
      display: none;
    }

    Hope this helps.

    #1216005
    pcnordhaug
    Participant

    Works on the dektop. Not from a mobile device. Is there a code to add for that?

    #1216619
    Rad
    Moderator

    Hi there,

    Please change it to this,

    // Adding Excerpt to Posts 
    function excerpt_read_more_link( $output ) {
    
       global $post;
    
      return !empty( $post->post_excerpt ) ? $output . '<a href="'. get_permalink($post->ID) . '" class="more-link"> Read More</a>' : $output ;
    
    }
    add_filter('the_excerpt', 'excerpt_read_more_link');

    That code will check if post excerpt is not empty, and it will add read more only if it’s not empty. That excerpt is the one you manually added.

    Thanks!

    #1219007
    pcnordhaug
    Participant

    This is into the function file istead right 😉

    But anyway – don´t work. The hole page goes blank if pasted in…

    #1219013
    Paul R
    Moderator

    Hi,

    Please note that you need to change the previously added code with the function name excerpt_read_more_link

    With this

    
    // Adding Excerpt to Posts 
    function excerpt_read_more_link( $output ) {
    
       global $post;
    
      return !empty( $post->post_excerpt ) ? $output . '<a href="'. get_permalink($post->ID) . '" class="more-link"> Read More</a>' : $output ;
    
    }
    add_filter('the_excerpt', 'excerpt_read_more_link');
    

    If that does not help, please provide wordpress admin login in private reply.

    Thanks

  • <script> jQuery(function($){ $("#no-reply-1166312 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>