get_posts() not working with multiple statuses
The correct post status for published posts is publish. Post statuses are in present tense (So publish, not published, and draft, not drafted).
The correct post status for published posts is publish. Post statuses are in present tense (So publish, not published, and draft, not drafted).
Can you not just go by date? Assuming you made a clean switch from classic to Gutenberg? Otherwise, there’s no definitive meta value, but you could just check the post content for common Gutenberg comments, such as <!– wp:paragraph –>.
You can set the orderby to post__in. Here is a superior post loop: $args = [ ‘post__in’ => [ 1, 2, 3, 4 ], ‘orderby’ => ‘post__in’, ]; $q = new \WP_Query( $args ); if ( $q->have_posts() ) { while ( $q->have_posts() ) { $q->the_post(); ?> <article id=”post-<?php the_ID(); ?>” <?php post_class(); ?>> <?php the_title(); … Read more
First, I second Q Studio comment: check Tom McFarlin’s post with a warning about using pre_get_posts. More specifically, pre_get_posts works everywhere, including RSS and dashboard, and you might want to exclude your logic from such places. That said, if I understood correctly what you are trying to do, you can achieve it by using author__in … Read more
You could use NOT EXISTS as the value for comparem, you could also check for empty value if thats relevant This code only checks if hidden meta does not exists $postsForSitemap = get_posts([ ‘numberposts’ => -1, ‘orderby’ => ‘modified’, ‘post_type’ => [‘post’, ‘page’], ‘order’ => ‘DESC’, ‘meta_key’ => ‘hidden’, ‘meta_compare’ => ‘NOT EXISTS’ ]; This … Read more
http://wordpress.org/extend/plugins/oldest-2-newest-redux/ it takes your oldest post and reposts it in the front every 24 hours, but you can change the hours on the php file in the plugin folder not sure if this is what u are looking for.
I believe the issue is that the underlying MySQL query requires a LIMIT clause to go with the OFFSET clause. (I tried to verify this about MySQL and found this https://stackoverflow.com/questions/255517/mysql-offset-infinite-rows ). Since MySQL can’t accept those parameters (offset without a limit), WordPress seems to drop the offset argument. It’s still a little hacky, but … Read more
This would be an appropriate use of query_posts(), with a post custom meta query. Since you’re querying by meta_key=featured_article&meta_value=on, you would then exclude on the same parameters. <?php // Setup the custom meta-query args $exclude_featured_args = array( ‘meta_query’ => array( array( ‘key’ => ‘featured_article’, ‘value’ => ‘on’, ‘compare’ => ‘!=’ ) ) ); // globalize … Read more
The post_excerpt column is a string and is not filterable using “IS NOT NULL” . To query for an empty string you can use the != operator. function posts_where_excerpt_not_empty( $where ) { $where .= ” AND post_excerpt != ” “; return $where; } Also get_posts suppresses filters by default so you will need to call … Read more
The easy way is to just use a PHP based reader and parse/output the results. Maybe your CMS already has one but if not and it’s based on PHP you can use, MagpieRSS SimplePie Simplexml Then you simple point it to your categories /feed, like –> www.example.com/your_category/feed You can easily customize a feed to show … Read more