• Hi,

    really nice plugin!! But one little problem I have. How can I exclude the current post. I find how I exclude IDs but is the a variable or something?

    Thanks for help!
    I hope there is a solution.

    Sebastian

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Rafał Gicgier

    (@gicolek)

    Hello Sebastian,

    Thanks for the comment. You can get the id of the post from the post edit screen, while hovering on the “Edit” button or by simply editing it and fetching it from the URL address.

    In the video I explained how to do it: https://www.youtube.com/watch?v=cv9BuKcfbhk

    Let me know if it works.

    Cheers!

    Thread Starter sebastian1234

    (@sebastian1234)

    Hi Gicolek,

    thank you for your fast answer. Yes I know to exclude individually posts and how I finde the ID. But I need a dynamic solution. So that the current post that I visit not displays in the sidebar.

    Thanks for your help!

    Plugin Author Rafał Gicgier

    (@gicolek)

    Hey,

    I thought you had this problem using a shortcode on a post.

    This is unachievable without programming, you’d have to hook into “acf_rwp_query” and paste the code inside your functions.php file.

    If you’re not comfortable with that I can code a sample for you on one of the default templates.

    Cheers,
    Rafal

    Thread Starter sebastian1234

    (@sebastian1234)

    Hi Rafal,

    thanks for your help. I can only program a little, so if you could code me a php snippet for the function.php, that would be totally great!

    Thank you
    Sebastian

    Plugin Author Rafał Gicgier

    (@gicolek)

    Alright. I’ll get back to you by the end of the week.

    Cheers!

    Thread Starter sebastian1234

    (@sebastian1234)

    Hi Rafal,

    do you found a solution?

    Thank you again.
    Greetings
    Sebastian

    Plugin Author Rafał Gicgier

    (@gicolek)

    Hello Sebastian,

    Unfortunately not yet. I got a flu during the weekend and couldn’t have worked at all. I’ll get back to you ASAP, sorry for the delay.

    Plugin Author Rafał Gicgier

    (@gicolek)

    Hello Sebastian,

    Here’s the promised code for you:

    add_filter( 'acf_rwp_query', 'wp_doin_exclude_current_post', 10, 1 );
    
    function wp_doin_exclude_current_post($query_args) {
    	global $post;
    	if ( $post->ID ) {
    		if ( isset( $query_args['post__not_in'] ) ) {
    			$query_args['post__not_in'][] = $post->ID;
    		} else {
    			$query_args['post__not_in'] = array( $post->ID);
    		}
    	}
    	return $query_args;
    }
    

    You’ll need to put in the functions.php of your active theme. Let me know if it works for you 🙂

    Cheers,
    Rafal

    Thread Starter sebastian1234

    (@sebastian1234)

    Hi Rafal,

    thank you very much. I’m a little bit busy and had just short time to test it, but it seems to work.

    Big thank you again, very nice!!

    Maybe you include it in your plugin, I think it is a important feature.

    Greetings
    Sebastian

    Plugin Author Rafał Gicgier

    (@gicolek)

    Thanks Sebastian,

    I will appreciate a review if possible 😛

    I will think about it having it included if I get the others to ask for such a feature.

    You were the first one I think.

    Have a nice day!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Exclude the current post’ is closed to new replies.