Filter post by current 2 differents users id

Based on wordpress reference for WP_QUERY you can use author__in to filter by more than one author. It uses an array of user ids. Here is your code with the needed changes: function list_cpt_by_author_id(){ $user = get_current_user_id(); $authors_id = array(“1”, $user); $custom_terms = get_terms(‘custom-tax’); foreach($custom_terms as $custom_term) { wp_reset_query(); $args = array( ‘post_type’ => ‘artigos’, … Read more

In WordPress how do you create a custom post type with the author’s name in the slug?

My plugin Custom Post Permalinks allows you to set permalink structures for custom post types and it supports post authors as part of a permastruct. However, while my plugin will enable you to set up that structure, I don’t suggest using that structure. That structure will essentially make WordPress interpret all top-level pages as 404 … Read more

How can I show/add/save custom metaboxes as an Array of values?

You just have to modify the name attribute of the generated input fields from p_clr to p_clr[]. $_POST[‘p_clr’] will then be an array with the values of all the input fields. public function prod_colors_box() { global $post, $p_clr; $p_clr = array(); $p_clrs = get_post_meta( $post->ID, ‘p_clr’ ); ?> <div id=”p_colors”> <?php foreach( $p_clrs as $key … Read more

How can you handle rewrite rules for custom post types with option to filter on custom taxonomy terms?

This is what I’ve used in the past for a similar requirement; register_post_type(‘movie’, array( ‘rewrite’ => array(‘slug’ => ‘movie’) )); register_taxonomy(‘movie_location’, ‘movie’, array( ‘rewrite’ => array(‘slug’ => ‘movies’) )); /** * Add rewrite rules for ‘base’ archives. * @param object $r Instance of {@see WP_Rewrite} */ function my_custom_rewrite_rules(&$r) { $rules = array( ‘movies/page/?([0-9]{1,})/?$’ => ‘post_type=movie&paged=’ … Read more

How to insert content from another Custom Post type into Post?

Currently the best way I know to handle that is the Posts 2 Posts plugin: http://wordpress.org/extend/plugins/posts-to-posts/ Here’s an example showing how to set up the custom post types (if you already have them it’s more for other’s benefit who might be reading this) as well as the function call to p2p_register_connection_type() needed by the plugin … Read more