WordPress.org

Ready to get started?Download WordPress

Forums

Q and A FAQ and Knowledge Base for WordPress
Plugin conflict with custom excerpt "continue reading" link (5 posts)

  1. sanjoyroy
    Member
    Posted 1 year ago #

    I use custom excerpts, which currently don't have the "continue reading->" link displayed.

    I installed the Q&A plugin, and used the shortcode on my home page - worked fine there. But it also makes the "continue reading" link reappear on all the excerpts, which I don't want. When I disable the plugin, all the excerpts revert back to normal.

    Any ideas?

    http://wordpress.org/extend/plugins/q-and-a/

  2. dcavins
    Member
    Posted 1 year ago #

    Hi Sanjoyroy-

    I had this same issue. The plugin developer is using a series of functions adapted from Twenty Eleven to modify the_excerpt() read-more links. The functions start at line 172 in /wp-content/plugins/q-and-a/inc/functions.php. If you want to disable them, add these lines to your theme's functions.php file:

    remove_filter( 'excerpt_more', 'qaplus_auto_excerpt_more' );
    remove_filter( 'get_the_excerpt', 'qaplus_custom_excerpt_more' );
    remove_filter( 'excerpt_length', 'qaplus_excerpt_length' );

    Removing filters can be tricky, sometimes. Read more here: http://codex.wordpress.org/Function_Reference/remove_filter

    Developer: You can target these functions to only affect the qa_faqs post type:

    /**
     * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and twentyeleven_continue_reading_link().
     */
    
    function qaplus_auto_excerpt_more( $more ) {
    	$post_type = get_post_type();
    
    	if ( $post_type == 'qa_faqs' ) {
    		return ' …' . qaplus_continue_reading_link();
    	}
    }
    add_filter( 'excerpt_more', 'qaplus_auto_excerpt_more' );
    /**
     * Adds a pretty "Continue Reading" link to custom post excerpts.
     *
     */
    
    function qaplus_custom_excerpt_more( $output ) {
    	$post_type = get_post_type();
    
    	if ( has_excerpt() && ! is_attachment() && $post_type == 'qa_faqs' ) {
    		$output .= qaplus_continue_reading_link();
    	}
    	return $output;
    }
    add_filter( 'get_the_excerpt', 'qaplus_custom_excerpt_more' );

    -David

  3. sanjoyroy
    Member
    Posted 1 year ago #

    Thanks David - you figured it out!

    In fact, I already changed my plugin to FAQ Manager, which works fine for what I need to do, so I don't have to worry about the filters (thankfully - you say that it can be tricky, and to me it *looks* tricky!).

    I hope the developer takes note of your code though.

  4. stickFinger
    Member
    Posted 1 year ago #

    Hi all

    Just to add one more side effect:
    after hours struggling and trying to find why for god sake the "Continue reading-->" string did not get translated i´ve finally found it around line 188 of "functions.php"

    function qaplus_continue_reading_link() {
    	return ' <a href="'. esc_url( get_permalink() ) . '">' . __( 'Saiba Mais <span class="meta-nav">&rarr;</span>', 'qa-free' ) . '</a>';

    it seems that the plugin overrides all possible translations even if you are using a custom theme.

    Also the plugin´s language files are overrided by functions.php

    i hope it helps someone else

  5. rajaman
    Member
    Posted 1 year ago #

    Thank you David! Adding the mentioned "remove filter" code to the theme's functions.php fixed the issue for me. :-)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.