the answer for all question about Oxygen Builder plugin and WordPress



HI all, I wonder if any of you can help. We’ve written a function that returns a boolean but requires the post_id of the custom post type to work. As we want to use this function as a condition (using the Php Function Return Value option in the Dynamic Data of the conditions dialog), within the oxygen template we are using, is there a way we can pass the post Id in to the Function Argument? The template is assigned to the custom post type but just cannot figure out how to pass the post id into the argument. Any help would be massively appreciated.


Whistle Design Set

Blogzine Design Set

  1. Sridhar says

    Generally speaking there’s no need to specify the current post ID in such functions since WP automatically takes care of that for us.

    Can you pastebin the function definition and provide the link?

  2. Allen says

    First, I would take whatever solution Sridhar Katakam suggests. Lol.

    Second, I’ve used get_the_ID() within the function in this scenario to get the ID of the current post.

    If you want the function available from more than the singular template, you can use something like Advanced Scripts. Make the function take a parameter for the post ID with default assignment to NULL. Then in the function use get_the_ID() to assign a value if NULL. For example…

    function some_function( $post_id = NULL) {
    $post_id = $post_id ?? get_the_ID();
    // do something…

  3. Chris says

    Hi guys, many thanks again to you both. We did manage to get the logic sorted out in a code snippet (like you suggested Allen) as the post_id etc are available. However, we have created the condition and although it’s returning the correct true or false value, it doesn’t appear to work on the template. We have 2 divs, 1 should only show if our condition (Is User Registered) is false and the other should show only if the condition is true. Both divs either show or don’t show despite the right value being returned (using Echo to see). It’s very confusing as to why this is and I think we may have the Condition setup wrong. Anyway, here’s a Pastebin of the code (table names removed for security :D) and would be most grateful if you could possibly have a look and see what the issue may be.
    Many thanks guys

Leave A Reply

Your email address will not be published.

Oxyrealm Docs OxyMade - Oxygen Builder Design Set Mega collection