wp_insert_post works, but the post isn’t visible in the admin post list or front end

The problem is $postarr[“post_status”] = “published”; you should change it to $postarr[“post_status”] = “publish”; // Set it to ‘publish’, not ‘published’ Now, this is a bit off topic, but you may want to omit the following (those are created by the wp_insert_post() by default): $postarr[“post_date_gmt”] = date(‘Y-m-d H:i:s’, time()); $postarr[“post_date”] = date(‘Y-m-d H:i:s’, time()); $postarr[“post_modified”] … Read more

Easy way to delete 70k posts and attached media?

If you know how to find the posts, then we can use WP CLI to do a 2 step process. First, grab all the post IDs in those categories using wp post list E.g. posts=$(wp post list –field=”ID” –category__in=”1,2,etc”) wp post delete $posts –force Then we can plug the values in posts into wp post … Read more

move blog posts from one wordpress to another

It depends on your exact situation. If there’s nothing in your new blog you can just point your new WP install at your old database (see questions on migrating) If there is content in your new WP instance and what you’re wanting to do is merge content, then do an export from the old site, … Read more

Posts are being redirected to xampp home page

Your rewrite rule is wrong. The existing rule is for when the site is at root– http://localhost. You site is at http://localhost/highimpact. The final rewrite rule should, I believe, RewriteRule . /highimpact/index.php [L]. If you go to wp-admin->Permalinks, and save the settings WordPress will rewrite the rules or tell you what the rules need to … Read more

How can I hide the sidebar from a specific post?

Here’s an idea I mentioned on Twitter. function special_post_template( $template ) { // Identify a single query for the special post if ( is_single() && 10 == get_the_ID() ) $template = get_template_directory() . ‘/special-single.php’; return $template; } add_filter( ‘template_include’, ‘special_post_template’ );

wp query with dynamic taxonomies and terms?

Here is one idea for a dynamic multiple taxonomy query: // construct the tax-query: $tax_query = array( ‘relation’ => ‘AND’ ); // check if movie_genre taxonomy is to be included if( $bMovieGenre ){ $tax_query[] = array( ‘taxonomy’ => ‘movie_genre’, ‘field’ => ‘slug’, ‘terms’ => array( ‘action’, ‘comedy’ ) ); } // check if actor taxonomy … Read more

How Can i Get 5 Recent Post Title With Corresponding Link?

This sounds like an additional Loop on that page, right? You might want to use: <ul> <?php $posts_query = new WP_Query(‘posts_per_page=5’); while ($posts_query->have_posts()) : $posts_query->the_post(); ?> <li><a href=”https://wordpress.stackexchange.com/questions/20489/<?php the_permalink(); ?>”><?php the_title(); ?></a></li> <?php endwhile; wp_reset_query(); ?> </ul> Also read more here: http://codex.wordpress.org/The_Loop#Multiple_Loops_in_Action

how to programmatically change post tags

The key function you’re looking for here is wp_set_post_tags(). To add the tag ‘awesome’ to post 98, wp_set_post_tags( 98, array( ‘awesome’ ), true ); Note that the true parameter means that this tag will be added to the existing post tags. If you omit this value, it defaults to false, and the existing post tags … Read more