Support » Fixing WordPress » Preview-only post abstracts

  • Hi!

    I am currently working on a site featuring a Restrict Content Pro subscription system, with which I will allow subscribers access to the blog page.
    However, I would like to make the previews of posts publically accessible. Essentially, this could look like a standard post grid/list – the only difference being that the “Read full post ->” button links not to the full post but instead refers to the subscription page.
    This, of course, should happen automatically for every new post.

    Any idea how I could do this? Or any workaround?

    I am super looking forward to any help! 🙂

    Thanks & all the best,

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz


    Well, you could have a template for non-subscribers that calls the_excerpt() instead of the usual the_content(). The excerpt will be auto-generated (55 chars long) from the content if an excerpt is not defined separately. In the auto-generated case, “[…]” is appended to the output text. You can use the “excerpt_more” filter to make this be a link to your subscription page instead.

    The thing is though, I’m not sure how non-subscribers would get to this excerpt template because I’m not sure how Restrict Content Pro works. For questions about the plugin itself, you should ask through technical support at the site where you acquired the plugin.

    One possibility would be to use the “template_include” filter to serve a different template to non-subscribers, but depending on how the plugin works, this alternative template may still not be served due to plugin interference.

    Thread Starter briefschreiben


    Hey, thanks a lot for your suggestion!
    I will try this out once I have set up the Restrict Content Pro (which, quite straightforwardly, allows to hide and show certain pages to certain membership levels). So, I might be able to display a page with the_excerpt() to non-subscribers and a page with the_content() to logged in subscribers.
    Thanks again, I’ll keep you posted!

    Thread Starter briefschreiben


    Hm, I somehow don’t manage getting this to work.

    In my child theme folder on cPanel, I have added a page-{pagename}.php file which is a duplicate of the parent theme’s page.php file.

    To this, I have appended the following:

    global $my_class;
    remove_filter( 'the_content', 'the_excerpt', array($my_class, 'class_filter_function') );
    remove_filter( 'the_content', 'the_excerpt', 'wpautop' );


    function child_theme_setup() {
    	remove_filter( 'excerpt_length', 'thb_supershort_excerpt_length' ); 
    add_action( 'after_setup_theme', 'child_theme_setup' );

    (targeting directly ‘excerpt_length’, ‘thb_supershort_excerpt_length’ which have been used by my parent theme for the blog style the page is using)

    as suggested here in order to remove existing twists to the Read more button,


    function new_excerpt_more($more) {
           global $post;
    	return '<a class="moretag" href=""> Read article...</a>';
    add_filter('excerpt_more', 'new_excerpt_more');

    in order to define a new target for the button which should now be called “Read article …”.

    Unfortunately, nothing has changed on the front end. What have I done wrong?

    • This reply was modified 2 years, 2 months ago by briefschreiben.
    • This reply was modified 2 years, 2 months ago by t-p.
    Moderator bcworkz


    In the first snippet you have too many arguments to remove_filter(). You can only remove one filter at a time. Call once to remove from “the_content”, then call again to remove from “the_excerpt”. The trouble with remove_filter() is there is no way to know if it was successful except by the fact the filter effect is not happening. A lot of similar functions return either true of false to show success so your code immediately knows the outcome. Not remove_filter().

    That would not affect the functioning of the “excerpt_more” filter. The code you have is fine, it should work. Are you sure the front end request is using a template that calls the_excerpt()? Do you have any caching on the site? At least flush your browser cache. Your host could also have caching in effect. If so, there ought to be a way to flush it from the hosting control panel.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Preview-only post abstracts’ is closed to new replies.