How to use a custom post type as front page?
Easiest way to display single post on front page would be: global $wp_query; $wp_query = new WP_Query( array( ‘p’ => ‘POST ID HERE’ ) ); include( ‘single-POSTTYPE.php’ );
Easiest way to display single post on front page would be: global $wp_query; $wp_query = new WP_Query( array( ‘p’ => ‘POST ID HERE’ ) ); include( ‘single-POSTTYPE.php’ );
As far as I know there is no such parameter as post_type_cat, you want to use either cat or if querying posts in a custom taxonomy you would use a taxonomy query. Category query example; $query = new WP_Query( ‘cat=2,6,17,38’ ); or $query = new WP_Query( ‘category_name=staff’ ); See the following Codex entry for even … Read more
Note that here you’re overriding the paging of the main query, with the posts_limits filter, by using hardcoded values: ‘LIMIT 0, 25’ where 0 is the offset and 25 is the number of posts to display. So in this case I would just use pre_get_posts with $query->set( ‘posts_per_page’, 25 ); and we don’t have to … Read more
This is directly related to, and a consequence of WordPress.com VIP At VIP, we deal with sites that range in the hundreds of millions of page views per week. As a result, situations that can slow down your site are much more noticeable at that scale than on a small shared host, but this still … Read more
Normally you would just specify a meta_value, e.g.: $args = array( ‘post_type’ => ‘business’, ‘meta_query’ => array( array( ‘key’ => ‘specials’, ‘value’ => ‘these are not the specials you are looking for – Obi Wan Kenobi’ ) ) ); However because your post meta is actually a data structure, a serialised PHP array/object, that’s not … Read more
You can use ‘posts_orderby’ filter to change the SQL performed. Note that: using get_posts() you need to set ‘suppress_filters’ argument of false for the filter to be performed if you don’t explicitly set ‘post_status’ you’ll get only published posts (so no much to order) Code sample: $filter = function() { return ‘post_status ASC’; }; add_filter(‘posts_orderby’, … Read more
Yes. To give you some historical perspective WordPress core: is relatively old code base, code volume tends to grow over time; has extreme commitment to backwards compatibility, as result it’s extremely rare for code to be removed from core; is written in essentially obsolete dialect of PHP version 5.2 (which it remains compatible with), which … Read more
meta_query and orderby are seperate parameters, you just put them together in an array. You will have to do one then the other. e.g. <?php $args = array( ‘post_type’ => ‘property’, ‘meta_query’ => array( array( ‘relation’ => ‘AND’, ‘city_clause’ => array( ‘key’ => ‘city’, ‘compare’ => ‘EXISTS’, ), ‘street_clause’ => array( ‘key’ => ‘street_name’, ‘compare’ … Read more
Case #1: Simple Offset You want to ‘offset’ posts of a category archive by ‘n’, i.e. you simply don’t want to show the first/latest ‘n’ posts in an archive. That is, (considering the posts_per_page setting in WP Dashboard > Settings > Reading is set to 10) you want posts 11 to 20 to be shown … Read more
Revisited and simplified answer: You can try: $args = [ ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘category_name’ => ‘projects’, ‘_name__like’ => ‘proj*’ // <– our new input argument! ]; $my_query = new WP_Query( $args ); where we’ve created the _name__like input argument. It supports wildcard *, for example: ‘_name__like’ => ‘a*b*’ Note that draft posts … Read more