How set featured posts using checkbox in post edit screen?

You can do this by following these steps: Add a custom meta box to your posts Create a function to save the meta data using the save_post action Add the ‘meta_key’ query argument to whatever query you are using. Place this in your themes functions.php file: function register_post_assets(){ add_meta_box(‘featured-post’, __(‘Featured Post’), ‘add_featured_meta_box’, ‘post’, ‘advanced’, ‘high’); … Read more

How to force excerpts / teasers in the loop

EDIT OK, there is a very hidden native function, get_extended() that I never knew about and greatly explained by @kaiser in his answer. My answer should only be an extension to the answer by @kaiser ORIGINAL ANSWER There is no native function to do this. The best here would be to use a PHP function … Read more

how to override woocommerce specific loop or archive-product.php [closed]

The WooCommerce templating works in different ways depending on your needs and/or skills. The function: <?php wc_get_template_part(‘content’, ‘product’); is the WooCommerce equivalent of WordPress core template function: <?php get_template_part(‘filename’); It is important to know that this is the same as php require but without using .php extension at the end. Before you do any of … Read more

Show posts without term

You cannot use the same object of WP_Query twice. Therefore you need to create another one with a tax_query parameter to fetch posts which are not assigned to any term. //fetch all reviews which have no assigned term in ‘review-product’ $taxonomy = ‘review-product’; $post_type=”reviews”; $args = [ ‘post_type’ => $post_type, ‘tax_query’ => [ [ ‘taxonomy’ … Read more

group search results by post type?

You can run the same loop multiple times by using rewind_posts() to output each type separately. if( have_posts() ){ $types = array(‘post’, ‘lesson’, ‘series’); foreach( $types as $type ){ echo ‘your container opens here for ‘ . $type; while( have_posts() ){ the_post(); if( $type == get_post_type() ){ get_template_part(‘content’, $type); } } rewind_posts(); echo ‘your container … Read more

remove tags from the_content

By default, WordPress adds paragraph tags to category descriptions. Stop this by adding the following to your functions.php file // Remove p tags from category description remove_filter(‘term_description’,’wpautop’); Simple and easy (codeless). Thank you

Loop within a loop?

You can create any number of loops as you wish by creating more WP_Query objects $query = new WP_Query($args); while ($query->have_posts()) : // initialization for $inner_args & backup the current global $post $inner_query = new WP_Query($inner_args); while ($inner_query->have_posts()) : // do something endwhile; // restore the global $post from the previously created backup endwhile; EXPLANATION … Read more

Is it possible to define a template for a custom post type within a plugin independent of the active theme?

You need to use the template_include filter which is the generic filter for all template inclusions. add_filter( ‘template_include’, ‘my_plugin_templates’ ); function my_plugin_templates( $template ) { $post_types = array( ‘project’ ); if ( is_post_type_archive( $post_types ) && ! file_exists( get_stylesheet_directory() . ‘/archive-project.php’ ) ) $template=”path/to/list/template/in/plugin/folder.php”; if ( is_singular( $post_types ) && ! file_exists( get_stylesheet_directory() . ‘/single-project.php’ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)