how to get post order by post id wp_query?

OK, so you want to define posts order by yourself. WP_Query allows you to do that – you’ll have to use orderby => post__in to achieve it. And that’s what you do. So why isn’t it working? Because of a typo 😉 Ordering posts by post__in preserves post ID order given in the ‘post__in’ array. … Read more

How can I add content to a post that only shows in single-post mode?

Looking at your specific example … You probably want to use a shortcode. Something like: add_shortcode(‘hide_from_summary’,’wpse_hide_stuff_here’); function wpse_hide_stuff_here($atts,$content){ global $post; // gives access to the post, so you can determine mode // don’t know if you’ll want/need $atts, so … generic stuff here $atts = shortcode_atts( array( ‘foo’ => ‘no foo’ ), $atts, ‘bartag’ ); … Read more

How I can use order by of the custom post title?

You can use the order and orderby param in WP_Query argument like below: $args = array( ‘post_type’ => ‘case’, ‘post_status’ => ‘publish’, ‘meta_key’ => ‘client’, ‘posts_per_page’ => 9, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ); $query = new WP_Query( $args ); It will list out your posts by title. For more information check official WordPress … Read more

Would Gutenberg be considered a PlugIn?

It’s slightly complicated. The default editor in WordPress is what’s properly called the “block editor”, but while this editor was being developed it was known as the “Gutenberg” project. The development on Gutenberg was done in the form of a plugin, which people could install for the purposes of testing and contributing. When WordPress 5.0 … Read more

Delete pubished and unpublished posts with wp_delete_post?

get_posts() can receive an argument describing which post status to operate. I would say something like this: function remove_all_kba_data(){ //remove articles $articles = get_posts( [ ‘post_type’ => ‘kb_kba’, ‘posts_per_page’ => -1, ‘post_status’ => [ ‘published’, ‘draft’ ] ] ); foreach( $articles as $article ) { //delete post, bypass trash wp_delete_post( $article->ID, true); } }

how to display an excerpt of the latest post on the homepage?

To show the excerpt from the latest post you can use query_posts. Example Query Posts Showing the Latest Post with the Featured Image: <?php query_posts(‘showposts=1’); ?> <?php while (have_posts()) : the_post(); ?> <h3 class=”home link”><a href=”https://wordpress.stackexchange.com/questions/1575/<?php the_permalink(); ?>”><?php the_title(); ?></a></h3> <?php the_post_thumbnail(); ?> <?php the_excerpt(); ?> <?php endwhile; ?> You will need to reset the … Read more

How to replace “Password Protected” text with icon in Admin

Try this (don’t forget to replace icon URL): add_filter( ‘display_post_states’, ‘password_protected_icon’ ); function password_protected_icon( $post_states ) { $text = __(‘Password protected’); $pos = array_search( $text, $post_states); if( false !== $pos ) $post_states[$pos] = ‘<img src=”http://i.stack.imgur.com/aIDa6.png” title=”‘.htmlspecialchars($text).'”/>’; return $post_states; }