Last active
October 12, 2025 18:07
-
-
Save ideadude/e5811456bfd333be0693bddb4b86059d to your computer and use it in GitHub Desktop.
Add a continue reading link on archive pages with Memberlite Theme.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Add a continue reading link on archive pages. | |
| * The link is not shown on the single post view. | |
| * If the user doesn't have access to the post, | |
| * the link is NOT shown, since there should already | |
| * be a message RE having to be a member to see. | |
| * | |
| * Hooks on the `memberlite_after_content_post` action. | |
| * | |
| * Note: This add potential extra DB SELECT for each | |
| * post in the view, which could cause issues on sites | |
| * with large numbers of posts on the page at a time | |
| * or with lower end hosting. | |
| */ | |
| function my_excerpt_continue_reading_link() { | |
| global $post; | |
| if ( is_single() ) { | |
| return; | |
| } | |
| if ( ! pmpro_has_membership_access( $post->ID ) ) { | |
| return; | |
| } | |
| ?> | |
| <p><a class="more-link" href="<?php the_permalink(); ?>"><?php _e( 'Click here to continue reading...', 'my-text-domain'); ?></a></p> | |
| <?php | |
| } | |
| add_action( 'memberlite_after_content_post', 'my_excerpt_continue_reading_link' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment