Variables in do_action
-
I am working on a modification to the Multipost Mu to enable custom posts. I have the code working pretty well except for he last step of adding the actions, which I would like to run in a loop, instead of hard coding. WordPress is not liking my attempt at entering a variable as the tag parameter.
if( function_exists( 'get_post_types' ) ){ function retrievePostTypes() { // Retrieve only Custom Post Types. Ignore builtin types. $custom_posts = get_post_types( array( 'public' => true, 'capability_type' => 'post', '_builtin' => false ), 'names' ); return $custom_posts; } }
This works great on “add_meta_box”.
$retrieved_types = retrievePostTypes(); foreach( $retrieved_types as $custom_post ) { add_meta_box('HMMPMU_meta', 'Multipost', 'HMMPMU_showSubBlogBoxes', $custom_post, 'side', 'low' ); }
This method DOES NOT work on the “do_action” side of things.
$retrieved_types = retrievePostTypes(); foreach( array ($retrieved_types) as $custom_post ) { add_action( 'publish_' . $custom_post, array(&$hmMultipostMU, 'multiPost'), 1); }
Any help would be appreciated.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Variables in do_action’ is closed to new replies.