Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter s1ngular1ty

    (@s1ngular1ty)

    Sorry wrong forum, i think. Ill repost this in hacks. Feel free to delete

    I noticed that you managed to get it working vichitrachin

    Did you manage to resolve this? I’m having the same issue.

    Thread Starter s1ngular1ty

    (@s1ngular1ty)

    Having played around with this issue a litte more it seems my problem lies with this section of code:

    $vclLockedContent = $_POST['vclLockedContent'];  //lockedcontent
            if (get_post_meta($post_id, 'vclLockedContent', TRUE) != ''){
                    update_post_meta($post_id, 'vclLockedContent',$vclLockedContent);
            }
            else{
                    add_post_meta($post_id, 'vclLockedContent', $vclLockedContent);
            }

    It seems that when I remove all content from my wp_editor box and save it, it means it no longer does an update_post_meta() but always tries to add_post_meta() instead. At least that is my diagnosis.

    Can anyone suggest a better way of writing this if statement? I need a way of determing whether to do an add_post_meta or an update_post_meta.

    Thread Starter s1ngular1ty

    (@s1ngular1ty)

    Thanks for trying to help me esmi, I really appreciate it. But could you tell me how to pass arguments to the function given in the following statement.

    add_action(‘wp_head’,’vclAddtoHead’,10,2);

    The variables are just strings. I have simplified my code in the above examples, for ease of reading.

    The reason I thought I needed a do_action was due to the following link:

    http://wordpress.org/support/topic/passing-arguments-to-add_action?replies=8

    If ANYONE can tell me how to pass arguments with add_action I will be v gratefull.

    Thread Starter s1ngular1ty

    (@s1ngular1ty)

    OK let me take a step back.

    I have defined my function vclAddtoHead as to take two arguments:

    function vclAddtoHead($arg1,$arg2){
    echo $arg1;
    echo $arg2;
    }

    I want this function to echo the arguments in the head tags. So thought I needed a function as follows:

    add_action(‘wp_head’,’vclAddtoHead’);

    But I need at some point to actually give my two arguments to my function. So how do I do this? I thought I had to modify add_action so that it specifies that my function takes two arguments, as follows:

    add_action(‘wp_head’,’vclAddtoHead’,10,2);

    Am I correct so far?

    If so what, now? Where do I actually specify what my two arguments are?

    In short how do I pass arguments to a function used in an add_action?

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