• Resolved seoguru

    (@seoguru)


    On a specific spot in my bbpress forum, I would like to add related posts. I created the following code, which does show related posts on the right spot, but the arguments have no effect. What am I doing wrong? Thanks!

    add_action( 'bbp_template_after_replies_loop', 'jc_bbp_template_after_replies_loop' );
    function jc_bbp_template_after_replies_loop() {
    
    	$args = array(
    		'limit' => 8,
    		'show_metabox' => false,
    	);
        echo_crp($args);
    }
Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author Ajay

    (@ajay)

    show_metabox has no relevance for the display of the posts. It’s a function sitting in the backend to control it on post pages.

    The limit should work. Can you also pass: 'strict_limit' => true

    Thread Starter seoguru

    (@seoguru)

    Thanks about the show_metabox, but the main problem is that the construction in itself doesn’t function on my site. Whatever values I assign to the attributes (like the limit) of the echo_crp, there is no effect on the output. For example, are the values overruled by the main settings?

    Plugin Author Ajay

    (@ajay)

    The ones passed as the arguments should take precedence.

    What happens if you do echo get_crp($args); instead?

    Thread Starter seoguru

    (@seoguru)

    echo get_crp($args); gives no output.

    Take a look at this page. In the middle of the page you see four related posts, where ‘limit’ is set to 8. Also other attribute values have no effect (like post_types, etc.).

    • This reply was modified 8 years, 4 months ago by seoguru.
    Plugin Author Ajay

    (@ajay)

    Can you install Query Monitor and see what query is being generated for echo_crp

    Thread Starter seoguru

    (@seoguru)

    I installed Query Monitor and discovered that it was a caching problem… In the settings, caching was enabled, and therefore no calls were made. So, I’m making progress now, ‘limit’ is working, which leads to the following problem.

    I want to show related topics in my bbpress-forum, and expanded the code as follows (with post_types):

    	$post_types = array(
    		'topic' => 'topic',
    	);
    	$args = array(
    		'limit' => 3,
    		'post_types' => $post_types,		
    	);
            echo_crp($args);

    When I do that, no related posts are shown. The query as a result of echo_crp is:

    SELECT post_id, meta_value
    FROM wp_postmeta
    WHERE meta_key = 'crp_post_meta'

    Further up in the Query Monitor log I see a PHP-warning “parse_str() expects parameter 1 to be string, array given” in wp-content/plugins/contextual-related-posts/contextual-related-posts.php:363 as a result of these stack calls:

    parse_str()
    wp-content/plugins/contextual-related-posts/contextual-related-posts.php:363
    get_crp_posts_id()
    wp-content/plugins/contextual-related-posts/contextual-related-posts.php:147
    get_crp()
    wp-content/plugins/contextual-related-posts/contextual-related-posts.php:769
    echo_crp()
    wp-content/themes/education-pro/functions.php:814

    Any idea?

    Plugin Author Ajay

    (@ajay)

    This is helpful. Can you please try to disable the cache in the Settings page of the plugin? The meta query you see is from the cache.

    With the cache disabled you should be able to see the main query which includes the MATCH clause.

    Thread Starter seoguru

    (@seoguru)

    The query is now:

    SELECT DISTINCT wp_posts.ID
    FROM wp_posts
    WHERE 1=1
    AND MATCH (post_title,post_content) AGAINST (‘salaris linkbuilder He mensen, Ik ben sinds kort linkbuilder voor een bedrijf en ben wel benieuwd hoeveel andere linkbuilders betaald krijgen? hebben jullie een indicatie? En is het resultaat gericht bij sommigen of niet? mvg’)
    AND wp_posts.post_date < ‘2016-11-08 15:56:59’
    AND wp_posts.post_date >= ‘2013-11-09 15:56:59’
    AND wp_posts.post_status = ‘publish’
    AND wp_posts.ID != 23418
    AND wp_posts.ID NOT IN (292,292,2532,1797,902,2591,2423,2934,3395,3333,3292,3294,2617,3306,4271,4276,4278,3520,2587)
    AND wp_posts.post_type IN (”)
    LIMIT 0, 4

    The post_type is empty, while the call was not emtpy:

    $post_types = array(
    	'topic' => 'topic',
    );
    $args = array(
    	'limit' => 3,
    	'post_types' => $post_types,		
    );
    echo_crp($args);

    Do you have an idea? Thanks!

    • This reply was modified 8 years, 4 months ago by seoguru.
    Plugin Author Ajay

    (@ajay)

    Can you add this before the $args statement?

    
    $post_types	= http_build_query( $post_types, '', '&' );

    I’ll soon add another setting where post_types will take a comma separated list

    Thread Starter seoguru

    (@seoguru)

    Great, that works: only topics are shown now.
    I still have thumbnails, and would like to see plain links. Is there a setting for that as well? Then I’m finished…

    Thanks a lot!

    Plugin Author Ajay

    (@ajay)

    'post_thumb_op'            => 'text_only'
    

    That should work.

    Thread Starter seoguru

    (@seoguru)

    Well, it works partly: images are gone now, but the square box remains.
    See: https://www.seoguru.nl/seo-forum/topic/alt-attributen-en-image-sitemap-van-google/ (below the discussion).

    Plugin Author Ajay

    (@ajay)

    Hi, I just realised that you might have the custom styles turned on. If you need just the text, you can turn that off in the Settings page.

    Thread Starter seoguru

    (@seoguru)

    That did the job, thanks a lot!

    Plugin Author Ajay

    (@ajay)

    You’re welcome. Glad to have been able to help. Do consider a review of the plugin.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘arguments of echo_crp function have no effect’ is closed to new replies.