• Matthew

    (@mattrrosenberg)


    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)
  • I wish I had a answer for you but I just wanted to bump this because I am in very much need of having Multipost MU use Custom Post Types. And perhaps you figured it out?! ??

    Thread Starter Matthew

    (@mattrrosenberg)

    I have Multipost MU working on CPTs but it requires a direct editing of the code. I haven’t figured out how to enable it automatically based on registered post types.

    I can post the code on my paste bin and show you what mods I made and what mods you would need to make.

    Thread Starter Matthew

    (@mattrrosenberg)

    I think I need to revisit how I build the array based on the registered CPTs.

    Sure, that would be great. I really only need it for one Post Type anyway…thanks so much!

    Thread Starter Matthew

    (@mattrrosenberg)

    Just add your custom post type name after the “publish_”.

    If you registered custom post type “books” your code would look like this.

    add_action( 'publish_books', array(&$hmMultipostMU, 'multiPost'), 1);

    If you update the plugin, beware, it will overwrite your change.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Variables in do_action’ is closed to new replies.