Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter johndalton80

    (@johndalton80)

    Basically I have a function(x) which I want to execute every time a post is created and is a certain category.

    So i’ve place it in wp-admin/post.php, maybe there is an easier way to do this?

    Thanks ??

    Thread Starter johndalton80

    (@johndalton80)

    wp-admin/post.php.

    Thread Starter johndalton80

    (@johndalton80)

    Ok thanks, that makes sense.

    Could you perhaps direct me to how I might learn to do that? Or post a sample? (writing to the WP database).

    Thanks for your help, it’s MUCH appreciated.

    IH

    Thread Starter johndalton80

    (@johndalton80)

    Ok so I added this to functions, notice that I just used an echo for testing.

    function insert_stock_quote($new_status, $old_status, $post) {
    	if ( 'publish' == $new_status && !in_array($old_status, array( 'publish', 'private', 'trash' )) ) {
    		echo 'this goes at the top of the post';
    	}
    }
    add_action('transition_post_status', 'insert_stock quote', 10, 3);

    and got these errors when I published or when I hit upgrade, and it doesn’t work:

    Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'insert_stock quote' was given in /home/bhgadmin/public_html/vannet/wp-includes/plugin.php on line 395
    
    Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'insert_stock quote' was given in /home/bhgadmin/public_html/vannet/wp-includes/plugin.php on line 395
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/bhgadmin/public_html/vannet/wp-includes/plugin.php:395) in /home/bhgadmin/public_html/vannet/wp-includes/pluggable.php on line 890
    Thread Starter johndalton80

    (@johndalton80)

    Wouldn’t that only display text when I update the post then?

    For example:

    function insert_stock_quote($new_status, $old_status, $post) {
    if ( ‘publish’ == $new_status && !in_array($old_status, array( ‘publish’, ‘private’, ‘trash’ )) ) {
    echo get_quote();
    }
    }
    add_action(‘transition_post_status’, ‘insert_stock quote’, 10, 3);

    Also where would I write this code to have it generate static content?

    I’m a Newb at this so Thanks for your patience.

    John

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