migrate only recent posts

The built in WordPress export page (Tools > Export) has a date range selector. Can you move over the last month’s posts and delete the extras?

Get Category in save_post Hook

Unfortunately, no success after a test 🙁 I put the follwing: if ( get_post_status( $post_id ) === ‘publish’ ) { $post_title = apply_filters(‘the_title’, get_post_field(‘post_title’, $post_id)); $post_content = apply_filters(‘the_content’, get_post_field(‘post_content’, $post_id)); $taxonomy = “category”; $args = array(‘orderby’ => ‘name’, ‘order’ => ‘ASC’); $cat = wp_get_post_terms( $post_id, $taxonomy, $args ); $categorie = $cat[0]->name; I get the count … Read more

Get post attachment with post id

yes use this code here you can get attachment id if(isset($_FILES[‘myimage’]) && ($_FILES[‘myimage’][‘size’] > 0)) { // Get the type of the uploaded file. This is returned as “type/extension” $arr_file_type = wp_check_filetype(basename($_FILES[‘myimage’][‘name’])); $uploaded_file_type = $arr_file_type[‘type’]; // Set an array containing a list of acceptable formats $allowed_file_types = array(‘image/jpg’, ‘image/jpeg’, ‘image/gif’, ‘image/png’); if (in_array($uploaded_file_type, $allowed_file_types)) { … Read more

Make current post the homepage

You can use custom template for showing current post on your home page. Using ‘orderby’ => ‘date’ Like this example… $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => -1, ‘orderby’ => ‘date’ );

how to create a category with wp_insert_post and post_category

In order to add existing term or new term to post you need to use wp_set_post_terms by checking with term_exists and using wp_insert_term if it doesn’t. Something like this: $author_id = 1; $slug = ‘wordpress-post-created-with-code’; $title=”WordPress post created whith code”; $content=”This is the content of the post that we are creating right now with code. … Read more