get_posts includes “auto drafts”?
If you just want to return published posts, you can exclude the ‘post_status’ argument as by default it will just return published posts only. Having said that, the array works for me too though.
If you just want to return published posts, you can exclude the ‘post_status’ argument as by default it will just return published posts only. Having said that, the array works for me too though.
You can use add_image_size function to add new image size and can use wp_get_attachment_image to retrieve those custom size image.
As suggested in a comment, the best approach here will be to make use of a tax_query. You have much more flexibility and the ability to run more complex queries specially when you are working with more than one taxonomy (in this case category and post_tag). You can try something like this $args = [ … Read more
If you are looking to change value of categories, you can just take a vairable instead of taking constant value and increment based on category!
Hello bro try this will work ! $newsItems2 = get_posts( [ “post_type” => “post”, “post_status” => “publish”, “posts_per_page” => 3, “orderby” => “date”, “order” => “DESC”, “meta_key” => “news__type”, “meta_value” => “general”, ] );
You need a plugin like this https://wordpress.org/plugins/the-post-grid/ to show the post in grid view.
Not sure if this is exactly what you’re asking, but it sounds like you’re looking for nested loops. This will list the most recent 5 posts in every category on your site: foreach ( get_terms(‘category’) as $category ) { echo ‘<h2>’.$category->name.'</h2>’; echo ‘<ul>’; foreach ( get_posts( ‘cat=”.$category->term_id ) as $post ) { setup_postdata( $post ); … Read more
Instead of using get_posts, which you would use if you wanted to retrieve multiple posts in a loop, you should use get_post, which only retrieves one post by an ID. There is also a built-in excerpt so you might want to go with retrieving post_excerpt. function get_the_excerpt_id($post_id) { $find = get_post($post_id); $excerpt = $find->post_excerpt; $excerpt … Read more
Use the metaWeblog api instead: “metaWeblog.getRecentPosts”. This includes the permalink information. See here: http://mindsharestrategy.com/2010/wp-xmlrpc-metaweblog/
Possibly the place to do this would be in the 404.php file of your theme. If there isn’t one, create one and WordPress will pick up. Note: if you want to return “non-404” content from this file you will probably need to clear the headers and set the status to 200. I’ve done something very … Read more