How to set value in Query Loop?

You can run multiple nested WP_Queries as long as you reset_postdata() to get the outer loop back on track. $query_args = array ( ‘posts_per_page’ => ‘1’, ‘meta_key’ => $count_today, ‘orderby’ => ‘meta_value_num’, ); $outer_query = new WP_Query( $query_args ); while( $outer_query->have_posts() ) : // conditional if if( true ) { // change the query arg … Read more

Display post structure in function

Try running the post content through the do_shortcode() function before displaying it. $args = array(‘posts_per_page’ => -1,’post_type’ => ‘edge’); $edge_array = get_posts( $args ); foreach($edge_array as $e): echo do_shortcode($e->post_content); endforeach;

show only one category posts in admin

to show one specific category posts in admin all posts page (edit.php?post_type=post) you need to join term_relationships table by filtering posts_join and adding where clause by filtering posts_where. eg. add_filter( ‘posts_join’, ‘hide_attachments_wpquery_join’ ); function hide_attachments_wpquery_join( $join, \WP_Query $query ) { global $wpdb; if( is_admin() && $query->query[‘post_type’] == “post” ) { $join .= ” LEFT JOIN … Read more

Show with echo if a post has two or more categories

To answer your question, if placed within the Loop – after, typically, while ( have_posts() ) : the_post(); in a single.php file – the code will work as follows: The has_category( array( ‘x’, ‘y’ ) ) condition will be satisfied if the post is in either x or y, or both, regardless of whether it … Read more

Display posts from another page on home page in wp-editor

I created shortcode in functions.php: add_shortcode(‘projects’, ‘projects_shortcode’); function projects_shortcode($atts){ extract(shortcode_atts(array( ‘post_type’ => ‘project’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 3, //’caller_get_posts’ => 1 ), $atts)); $args = array( ‘post_type’ => $post_type, ‘post_status’ => $post_status, ‘posts_per_page’ => $posts_per_page ); global $post; $posts = new WP_Query($args); $out=””; if ($posts->have_posts()) while ($posts->have_posts()): $posts->the_post(); $overview_image = get_field(‘small_overview_image’); $out .= ‘<div … Read more

How to delete unnecessary custom post types in the UI

Currently there is no way on the backend (UI) for unregistering a post type, the process however is quite simple. Andrew Nacin provided some code over on https://core.trac.wordpress.org/ticket/14761 You can easily create a plugin with this function and have the CPT unregister. if ( ! function_exists( ‘unregister_post_type’ ) ) : function unregister_post_type( $post_type ) { … Read more

Posts not showing up on Blog page

In addition to setting a particular posts page, you have to have a theme that will accomplish your goal. Most likely your theme’s Page template, which is what is being balled by your blog Page, only outputs the content of your single Page. You can create a new Page template for this page in several … Read more

Post’s arent displaying

I just recreated your setup. I created a post-type called “supplier-showcase”. I created a taxonomy called “supplier-category”, and added a term with the slug “supplier-cakes”. Added some posts with and without the term “supplier-cakes”. Than I copied your code, inserted it in a simple page template, fixed the things I already mentioned, and reindented the … Read more