How to get post ID after removing that post?

There’s only one way I can see that you can get the ID after a post is deleted. If you’re using wp_delete_post to delete posts, you add a after_delete_post action hook where you will then do the other stuff that you need to do like the remove of page from sitemap, etc. The hook has … Read more

Set a minimal number for next user_id

You can access via phpMyAdmin and change the Auto Increment number to be your next user ID number. Open phpMyAdmin Go to SQL tab at the top. Enter the following: ALTER TABLE ‘wp_users’ AUTO_INCREMENT=32200906; Now create a new user and the ID should be 32200906

View post with specific category id and name which I selected in the backend (drop-down option)

Try this code. <?php $cat_id = get_theme_mod(‘cat_choose’, $defaults); ?> <p><?php echo get_cat_name( $cat_id ); ?></p> <hr> <?php $args = array( ‘post_type’ => ‘post’ , ‘orderby’ => ‘date’ , ‘order’ => ‘DESC’ , ‘cat’ => $cat_id, ‘posts_per_page’ => -1, ); $cat_posts = new WP_query($args); if ($cat_posts->have_posts()) : while ($cat_posts->have_posts()) : $cat_posts->the_post(); ?> <div> <div> <h1><?php the_title(); … Read more

What is $post->ID

The post ID. It’s not possible to say any more without more context. If I had to guess $post in this case is a WP_Post object that represents the current post and the author of the post wants to get some posts while excluding the current post. Just be aware that doing so this way … Read more

Query parsing only author ids

Assuming that you have an array of post objects in $my_posts… $authids = array_unique(wp_list_pluck($my_posts,’post_author’)); What you will get are the post authors for the current page of posts, not the post authors for all of the posts. If you want the authors for all of the posts you will have run another query. To run … Read more

How to define category ID in an array?

As Geert pointed out, your current conditional will always be true. An if() construct needs to be fed an expression. You’re feeding it a valid array, so that’s true. Always. So far this is basic PHP, regardless of whether in a WP environment or not. As can be read in Chris_O’s comment if ( is_category(‘some-cat’) … Read more