Adding meta boxes to custom post type

Let’s say your post type is named product. You register your metabox with … add_action( ‘add_meta_boxes_product’, ‘register_product_metabox’ ); function register_product_metabox() { // register the metabox } You get the post id in your callback per post object now: function metabox_callback( $post ) { $field = get_post_meta( $post->ID ); } This happens because WordPress calls 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’);

Exclude sticky posts from query

You should also use ignore_sticky_posts=1 (it’s default value is 0, so sticky posts aren’t ignored and returned at top of posts list). More on pagination parameters: http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters

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

Why isn’t my Meta_Query running?

If you haven’t assigned it to any hook and you don’t call it, then it can’t work – this function is never called. You should assign it to pre_get_posts hook, I guess (at least it looks so). Add this after your function: add_filter( ‘pre_get_posts’, ‘ah_meta_queries’ ); It should work fine then.