assign array of category to custom post type

Use the tax_input argument like this: $categories = array(51,52,53,54,55); $post_id = wp_insert_post( array( ‘post_content’ => ”, ‘post_name’ => $title_slug, ‘post_title’ => $title_slug, ‘post_status’ => ‘publish’, ‘post_type’ => ‘test’, ‘post_author’ => ‘me’, ‘post_excerpt’ => ”, // ‘post_date’ => $date, ‘post_category’ => $categories_id, // ‘tags_input’ => array($tags), ‘tax_input’ => array( ‘category’ => $categories ); )); Happy Coding … Read more

Dynamically add a unique number/identifier at the end of post titles

You will need to leverage the post_updated hook API of WordPress // You will need to leverage the <code>save post</code> hook API of WordPress add_action( ‘post_updated’, ‘save_post_callback’, 10, 3 ); //add_action(‘save_post’, ‘save_post_callback’); function save_post_callback($post_ID, $post_after, $post_before){ global $post; if ($post->post_type != ‘page’){ return; } // If you get here then it’s your post type so … Read more

Skip latest 3 posts from loop

You can use the pre_get_posts action to alter your main query. The codex has a note that using the action might break pagination. Have a look at this old question and answer, Changing Posts Per Page and offset with pre_get_posts It has code examples for using the pre_get_posts and how to handle the pagination problem … Read more