[Condition] Include/Exclude list of Post ID’s

A user in the Oxygen Facebook group was looking to use Oxygen conditions to include a certain section from their page only if the post had certain ID’s. Currently they need to add each Post ID manually.

I wrote a quick function that allows you to add all your post ID’s into 1 function reducing the number of conditions needed and making it cleaner.

php
function tct_post_id_check($post_ids){ $current_id = get_the_ID(); $post_id_array = explode("+", $post_ids); return in_array($current_id,$post_id_array) ? 1 : 0; }

To use:

Add condition with Dynamic data -> PHP return value

Function name = tct_post_id_check
Arguments = 25+32+45+26
(Replace with your Post ID’s, make sure to add a + between each number)

Then set the function == 1 or 0 depending on if it should show or not.

1 == show (true)
0 == hide (false)

Facebook post = https://www.facebook.com/groups/1626639680763454/posts/4262732010487528

👋🏻 Weekly Tutorial Digest

I send out a weekly newsletter with links to new tutorials written in the last week, you can subscribe below.

🔒I won't send you spam, I promise