Craig Craig - 4 years ago 74
PHP Question

Will renaming $args, when creating a Custom Post Type, cause any conflicts?

I am in the process of creating 2 Custom Post Types; 'Specials' and 'Recommended'. I have successfully created my 'Specials' Custom Post Type. I am now going to replicate the same process for my 'Recommended' Custom Post Type. That said, I am aware that if I simply copy and paste the relevant coding, then my 'Recommended' Custom Post Type will simply call the $args from the 'Specials' Custom Post Type.

The only way I can think of my 'Recommended' Custom Post Type calling it own $args is by renaming it to something like '$args_recommended' and registering both Custom Post Types as follows:

  • register_post_type( 'specials', $args );

  • register_post_type( 'recommended', $args_recommended );

I have not come across any errors as of yet, and it seems to be working for me, but is anyone aware of any potential conflicts this may cause. If so, could someone point me in the right direction of a 'best practice' approach.

Answer Source

It really doesn't matter what the name of your args array is. Use whatever you like, it will work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download