Add Metabox to all custom post types

The 4th parameter for add_meta_box() is the post_type. So if you’re calling it with post, it’ll only show on WordPress’s native posts. Try this: add_meta_box( ‘my-meta-box-id2’, ‘Enter your PDF location for your post category below:’, ‘cd2_meta_box_cb’, ‘your_custom_post_type_name’, ‘normal’, ‘high’ ); If you have multiple post types you’d like to attach this to, this should work: … Read more

What is the proper way implement a global $wp_rewrite?

It is not necessary to define $wp_rewrite in your function. The add_permastruct() and add_rewrite_rule() functions take care of that for you. Try removing the “global $wp_rewrite;” line and see if your code still works. The add_permastruct() function currently accepts three parameters. There is some backwards-compatibility logic in the function to correct for calls using the … Read more

Remove custom post type in url?

You need to add a custom rewrite rule in functions.php: function your_cpt_rewrite_rule() { add_rewrite_rule(‘(.*?)$’, ‘index.php?your_cpt=$matches[1]’, ‘top’); } add_action(‘after_theme_setup’, ‘your_cpt_rewrite_rule’);

Buddypress: Display multiple custom post types on member’s profile

This is the updated working code in stats-profile.php which together with code above in bp-custom.php (buddypress functions.php) gives me the title(s) of displayed user for multiple custom post types. <?php if ( is_user_logged_in() ): query_posts(array( ‘post_type’ => array( ‘post’, ‘portfolio’, ‘applicant’, ‘agency’, ’employer’ ), ‘author’ => bp_displayed_user_id(), ‘showposts’ => 3 ) ); ?> <?php while … Read more