custom sort posts in archive/taxanomy page

Put something along these lines in your functions.php: add_filter( ‘pre_get_posts’, ‘custom_get_posts’ ); function custom_get_posts( $query ) { if( is_category() || is_archive() ) { $query->query_vars[‘orderby’] = ‘name’; $query->query_vars[‘order’] = ‘ASC’; } return $query; } reference here (see the second answer)

WP_Query orderby not working on custom post_type

OK, I figured it pour reading about Orderby Parameters in WP_Query more carefully. I needed to set votes to meta_key and orderby to meta_value_num: $args = array( ‘post_type’ => ‘entry’, ‘meta_key’ => ‘votes’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’, ‘posts_per_page’ => 10, ‘post_status’ => ‘publish’ ); $loop = new WP_Query($args);

Stylesheet won’t load even when linked

Add the CSS to your child themes style.css file or load it using wp_enqueue_scripts add_action( ‘wp_enqueue_scripts’, ‘wpsites_load_custom_styles’ ); function wpsites_load_custom_styles() { wp_register_style( ‘custom-css’, get_stylesheet_directory_uri() . ‘/your-style.css’, false, ‘1.0.0’ ); wp_enqueue_style( ‘custom-css’ ); } Source

How do I show the post title if an advanced custom field hasn’t been used?

If in doubt, check the documentation first: https://www.advancedcustomfields.com/resources/get_field/ Check if value exists This example shows how to check if a value exists for a field. $value = get_field( ‘text_field’ ); if ( $value ) { echo $value; } else { echo ’empty’; } So, in for your case you would need to use: <?php $short_testimonial … Read more

WP_Query issues with argument posts_per_page

Try to add ‘post_type’ => ‘any’, ‘post_stauts’ => ‘any’, to your arguments and see what happens. This should retrieve posts in all post types with any post status. If it only retrieves 252 posts, then the other posts doesn’t not meet your criteria in your query. The other important thing is that with such an … Read more

Taxonomy related query not working

The final code I used was: <?php $slides_category = get_field(‘slider_category’); $args = array( ‘post_type’ => ‘slides_post_type’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘category’, ‘field’ => ‘id’, ‘terms’ => array( $slides_category ), ), ), ); $slides_loop = new WP_Query( $args ); if( $slides_loop->have_posts() ): while( $slides_loop->have_posts() ): $slides_loop->the_post(); ?> // Post content goes here <?php endwhile; … Read more