• Resolved mllapan

    (@mllapan)


    I managed to solve many things I wanted done with this plugin,but this one about excerpts I am failing.

    I tried:

    function lt_html_excerpt($text) { // Fakes an excerpt if needed
        global $post;
        if ( '' == $text ) {
            $text = get_the_content('');
            $text = apply_filters('the_content', $text);
            $text = str_replace('\]\]\>', ']]>', $text);
            /*just add all the tags you want to appear in the excerpt --
            be sure there are no white spaces in the string of allowed tags */
            $text = strip_tags($text,'<p><br><b><a><em><strong>');
            /* you can also change the length of the excerpt here, if you want */
            $excerpt_length = 55; 
            $words = explode(' ', $text, $excerpt_length + 1);
            if (count($words)> $excerpt_length) {
                array_pop($words);
                array_push($words, '[...]');
                $text = implode(' ', $words);
            }
        }
        return $text;
    }
    /* remove the default filter */
    remove_filter('get_the_excerpt', 'wp_trim_excerpt');
    
    /* now, add your own filter */
    add_filter('get_the_excerpt', 'lt_html_excerpt');

    This does not work.
    I know that PMPRO uses wp_trim_excerpt with priority 5, if I am right.
    I am not sure how to accomplish this, I need it only inside the_content, which means only in posts, not categories, archives, or elsewhere.

    I want that paragraph which shows be formatted as in the full post.
    For this, when someone gets a peek at an excerpt he or she would think that behind a paywall is such non-formated bad text, which will cause many people to bounce off this.

    I can not use more tags, it does not work in some themes I tried, and I have many posts I don’t have time to go through each and add this tag anyway.

    I think this should be offered inside the plugin by default, excerpts should be formatted.
    Maybe you have such a thing offered with the premium version, no idea about that, but it would be fair if we have this in the free version.
    I mean, if we earn, and we will with nice lead-in text, more than an ugly excerpt block, we can buy premium add-ons and support you.

    • This topic was modified 2 years, 3 months ago by mllapan.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Hey @mllapan,

    Thank you for reaching out to Paid Memberships Pro.

    We have a free code recipe where the preview content is blurred and fades out that may be useful to you, so please test this CSS: https://www.paidmembershipspro.com/premium-content-preview-blur-fade-text/

    Thread Starter mllapan

    (@mllapan)

    Hey, @michaelbeil,
    can you tell me at least how to disable Paid Membership Pro on the_content(); so I can create my shortcode and call the_content(); this inside?

    I tried it already, and I have my function working, while the_content still is affected by PMPRO inside the shortcode.

    I tried:
    remove_filter('the_content', 'pmpro_membership_content_filter', 5);
    but it does not work, PMPRO still affects the_content() after the shortcode is executed.

    For example such shortcode:

    
    function paywall( $atts, $content = null ) {
    if ( is_user_logged_in() ) {
         $content = apply_filters('the_content', get_the_content());
         echo $content;
    } else {
         $content = apply_filters('the_content', get_the_content());
         $sentences = explode(".", $content);
         $first_slice = implode(".", array_splice($sentences, 0, 5));
         $second_slice = implode(".", array_splice($sentences, 0));
         echo '<div class="non-paywall">'. html_entity_decode ( $first_slice ) .'.</div><div class="pmpro_content_message">Ovaj sadr?aj je samo za registrirane korisnike.<br><a href="/prijava">Prijava</a><a href="/registracija">Registracija</a></div>';
    }
    }
    add_shortcode( 'paywall', 'paywall' );
    

    Calling: <?php echo do_shortcode("[paywall]"); ?>
    Now if the first condition is met is_user_logged_in(), I still have PMPRO affect it on its own conditions, and content is displayed multiple times.

    If the first condition is_user_logged_in() is not met, I have the code from the paywall shortcode, plus again PMPRO message with it.

    This thread goes beyond the level of support we provide, so this would require some custom development to achieve. If you need help implementing this, you may reach out to a local WordPress developer or post a job request on https://jobs.wordpress.net.

    Plugin Support Theunis Coetzee

    (@ipokkel)

    Because there have not been any recent updates to this topic, we will be changing the status to resolved. If you have any new questions or if your issue persists, please feel free to create a new topic.

    Kind regards,
    Theunis C.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Show HTML formatting in excerpt’ is closed to new replies.