Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1383448
    bdestrempes
    Participant

    Hey guys,

    I’m using a custom read-more link with this on the Integrity stack:

    // Excerpt More String
    // =============================================================================
    
    if ( ! function_exists( 'x_excerpt_string' ) ) :
      function x_excerpt_string( $more ) {
        if (is_user_logged_in()) {
          return '  <div><a href="' . get_permalink() . '" class="more-link">' . __( 'Read More', '__x__' ) . '</a></div>';
        }
        else {
                return '<div><a class="more-link" href="' . wp_login_url(get_permalink()) . '">Log in to read more</a></div>';
        }
      }
      add_filter( 'excerpt_more', 'x_excerpt_string' );
    endif;
    
    // Content More String
    // =============================================================================
    
    if ( ! function_exists( 'x_content_string' ) ) :
      function x_content_string( $more ) {
    
        if (is_user_logged_in()) {
          return ' <div><a href="' . get_permalink() . '" class="more-link">' . __( 'Read More', '__x__' ) . '</a></div>';
        }
        else {
                return '<div><a class="more-link" href="' . wp_login_url(get_permalink()) . '">Log in to read more</a></div>';
        }
      }
    
      add_filter( 'the_content_more_link', 'x_content_string' );
    endif;

    This works fine on the general blog listing but the link doesn’t show up on category listings. I was under the impression categories would use the same function, am I missing something here?

    You can take a look on http://www.visionmountain.com/blog and http://visionmountain.com/category/consciousness-and-life-issues/

    Thanks.

    #1383914
    Rue Nel
    Moderator

    Hello There,

    Thanks for writing in! Do you have any other custom functions that may have some conflict in this? Would you mind providing us the url of your site with login credentials so we can take a closer look? This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.

    To do this, you can make a post with the following info:
    – Link to your site

    – WordPress Admin username / password

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    Thank you.

    #1384358
    bdestrempes
    Participant
    This reply has been marked as private.
    #1384580
    Jade
    Moderator

    HI there,

    I tried to login using the details you provided but it doesn’t seem to work.

    Kindly double check it so that we could assist you further.

    Thank you.

    #1384588
    bdestrempes
    Participant
    This reply has been marked as private.
    #1385062
    Rue Nel
    Moderator

    Hello There,

    Thanks for updating in! I have logged in and after that I am just seeing this:
    http://prntscr.com/ed36to

    Please allow us to view the admin page.

    Thank you.

    #1385069
    bdestrempes
    Participant

    User had no role set for some reason, should be fixed.

    #1385235
    Christopher
    Moderator

    Hi there,

    Login to read more link shows fine on archive page (see the attachment) but in blog page it doesn’t due to following blocks of code :

    .blog #read-more {
        display: none;
    }
    .blog .has-post-thumbnail .entry-content {
        display: none;
    }

    Please remove those blocks.

    Hope it helps.

    #1385386
    bdestrempes
    Participant

    Hi,

    The .blog class targets the http://visionmountain.com/blog page and not the individual category pages. .entry-content shows up on those pages (with body classes of .archive and .category, not .blog).

    #read-more is a div added to content.php to show users who are not logged in:

    <?php echo '<div style="text-align: center;" id="read-more"><a href="' . wp_nonce_url(wp_login_url(get_permalink()), 'login_') . '">Log in to read more</a></div>'; ?>

    However, logged in users should still see the regular Read More link at the end of the excerpt (added with the read more tag in the individual posts).

    #1385451
    bdestrempes
    Participant

    I fixed the problem by adding the following to my child theme’s content.php:

    <?php if (is_user_logged_in()) {
          echo ' <div><a href="' . get_permalink() . '" class="more-link">' . __( 'Read More', '__x__' ) . '</a></div>';
        }
        else {
                echo '<div><a class="more-link" href="' . wp_nonce_url(wp_login_url(get_permalink()), 'login_') . '">Log in to read more</a></div>';
        } ?>

    It feels more like a hack than anything else though, so I’m all ears if anyone has a better solution.

    Thanks.

    #1385700
    Rad
    Moderator

    Glad to hear that and thanks for sharing!

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