• Resolved Mppeter

    (@mppeter)


    Hello!

    There was a topic before and it was marked as resolved here. My question is that the code what was included in that thread is working? I pasted it in the flexible-posts-widget.php but it had no effect.

    https://wordpress.org/plugins/flexible-posts-widget/

    function current_recent_post( $args ) {
    	if( is_singular() && !isset( $args['post__in'] ) )
    		$args['post__not_in'] = array( get_the_ID() );
    
    	return $args;
    }
    add_filter( 'dpe_fpw_args', 'current_recent_post' );
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author DaveE

    (@dpe415)

    Hi Mppeter,

    You’d need to paste this code into your theme’s functions.php file. Cheers!

    Thread Starter Mppeter

    (@mppeter)

    Thanks for your fast answer. I didn’t mention but i tried that too and its not working.

    I’m using Genesis framework.

    Plugin Author DaveE

    (@dpe415)

    Sorry for the delay,

    I had a chance to test out the filter using the Genesis framework and their sample theme (the sample child theme StudioPress bundles with the Genesis Framework) and it works fine. Copied the code above into the genesis-sample theme’s functions.php file.

    However, there is an exception. Are you getting posts by Post Type and Taxonomy & Term or by Post ID in the widget? If you’re getting posts by ID, then the filter wouldn’t apply. In that case, you’d want to adjust the filter as follows:

    function current_recent_post( $args ) {
    	if( is_singular() )
    		$args['post__not_in'] = array( get_the_ID() );
    
    	return $args;
    }
    add_filter( 'dpe_fpw_args', 'current_recent_post' );

    If you aren’t getting posts by ID and the filter isn’t working, then the only other suggestion I have is that maybe another plugin or theme filter is causing the issue? I’ve found that other plugins/filters have been known to override FPW’s query settings when they use filters that are too lenient (apply to too many queries).

    Hopefully that helps.

    Thread Starter Mppeter

    (@mppeter)

    Thanks for looking after.
    Im getting posts by ID but the code you provided not working.

    Plugin Author DaveE

    (@dpe415)

    I’m not sure I’d be able to help you further at this point. As I stated, I am able to get the filter working just fine with Genesis for both Tax & Term or Post ID options. I’d suggest disabling other plugins to see if maybe there is a conflict with another plugin used on the site.

    Sorry

    Thread Starter Mppeter

    (@mppeter)

    I guess the problem theme related. I disabled every plugin and still showing the same post.

    It was more like a customization question. You could just send me away haha, but you spent your time testing it for me. Thank you very much.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Exclude current post in the list’ is closed to new replies.