• Resolved shaunbowen

    (@shaunbowen)


    Hi there, I have the WP Customer Area plugin, plus some paid add-ons installed on one of my websites. I have a piece of code in my theme’s functions.php file that adjusts the length of the post excerpt on the Archive pages:

    //Filter the except length to 80 characters.
    function mytheme_custom_excerpt_length( $length ) {
        return 80;
    }
    add_filter( 'excerpt_length', 'mytheme_custom_excerpt_length', 999 );

    When I activate your plugin, this code no longer works.

    Do you have any suggestions of an alternative code I can use to avoid this conflict, or a reason why your plugin affects wordpress excerpts?

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Thomas

    (@tlartaud)

    Hi,

    Does this happen in all pages of your site, or only on WPCA pages?

    The only place where we are affecting the excerpt length is https://gitlab.com/wp-customerarea/plugins/customer-area/blob/master/skins/frontend/master/cuar-functions.php#L223

    We only affect WPCA pages.

    You can remove that by using this code so the excerpt length will be the same as the one used on your site.

    
    remove_filter( 'cuar_excerpt_length', 'cuar_custom_excerpt_length', 999);
    

    Please, note that our support forums are located here: https://wp-customerarea.com/support/
    You’ll get answers within 24 hours on this one (except on holidays & weekends of course).

    Best regards.

    Thread Starter shaunbowen

    (@shaunbowen)

    This happens on all archive pages on the site, as long as the WPCA plugin is activated.

    Plugin Author Thomas

    (@tlartaud)

    What about the remove_filter code I Gave you? You can place it in your theme functions.php file.

    Regards.

    Thread Starter shaunbowen

    (@shaunbowen)

    Hi There, no adding that remove_filter code doesn’t sort the issue. When I activate your plugin, the exceprts still don’t honour my choice of length and also the ‘Read More’ text becomes an elipsis (…).

    Plugin Author Thomas

    (@tlartaud)

    Hi,

    What if, for testing purposes, you manually remove the following function in customer-area/skins/frontend/master/cuar-functions.php?

    if ( ! function_exists( 'cuar_custom_excerpt_length' ) ) {
    	/**
    	 * Custom excerpt length
    	 *
    	 * @param $length
    	 *
    	 * @return int
    	 */
    	function cuar_custom_excerpt_length( $length )
    	{
    		if ( cuar_is_customer_area_page( get_queried_object() ) || cuar_is_customer_area_private_content( get_the_ID() ) ) {
    			return 30;
    		} else {
    			return $length;
    		}
    	}
    
    	add_filter( 'cuar_excerpt_length', 'cuar_custom_excerpt_length', 999 );
    }
    

    Regards.

    Thread Starter shaunbowen

    (@shaunbowen)

    That didn’t work, but if a remove the code from lines 234 to 335, that DOES fix the issue!

    It looks like the function cuar_remove_auto_excerpt is the issue.

    Plugin Author Thomas

    (@tlartaud)

    Oh, nice catch.

    In this case, try to add this to your theme functions.php.
    Not tried but it should work.

    remove_action( 'after_setup_theme', 'cuar_remove_auto_excerpt', 1000 );
    remove_filter( 'cuar_excerpt_length', 'cuar_custom_excerpt_length', 1000 );

    Thank you for the report. I’ll check for the next updates if we need to make some changes on this point.

    Regards.

    Thread Starter shaunbowen

    (@shaunbowen)

    Unfortunately the above code added to my functions.php file did not fix the issue. The only way it works seems to be manually removing the code from the plugin files.

    Thread Starter shaunbowen

    (@shaunbowen)

    I’ve just noticed some interesting behaviour. When I change a post to use Siteorigin Page Builder, rather than the regular editor, the Excerpt length and ‘Read More’ text work properly again! So this bug only affects pages using the regular wordpress editor. Not tested with Guttenberg as I don’t use that.

    Plugin Author Thomas

    (@tlartaud)

    Hi,

    I have published a new release.

    I have edited our actual code so the excerpts of your site will only be affected on WP Customer Area pages & posts.

    I hope that this will fix your issue.

    Regards.

    Thread Starter shaunbowen

    (@shaunbowen)

    I’ve updated the plugin and it does indeed seem to have sorted the issue! Many thanks.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Plugin conflicts with code to edit WordPress Excerpt Length’ is closed to new replies.