0

I have a lot of custom post types and i want to create them all with in the same function, so is there any way to send parameters to the function when i'm creating the custom post type.

I thinking of something like this:

function custom_poster($pluralName, $singularName) {
   // Create custom post type
}

add_action( 'init', 'custom_poster' );
0

if you are not taking care about backward compatibility (works only when run under PHP 5.3 and later), you can employ the anonymous function:

add_action( 'init', function() {
    $pluralName = 'PluralName';
    $singularName = 'SingularName';
    custom_poster( $pluralName, $singularName );
    } 
);

Or closure

$singularName = 'Singular Name';
$pluralName = 'Plural Name';
add_action( 'init', function() use ($singularName, $pluralName) {
   custom_poster( $pluralName, $singularName );
} );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.