Resetting a Query using wp_reset_query() or wp_reset_postdata() does not work
I removed the following line and fixed. <span><?php the_field(‘repeater_related_items’); ?></span>
I removed the following line and fixed. <span><?php the_field(‘repeater_related_items’); ?></span>
pre_get_posts and WP_Query uses the exact same parameters, so if you need to know which parameters you can use with pre_get_posts, simply visit the WP_Query page in the codex. There is another trick which you can use to get all the parameters (query_vars) you can use. Just add this on the page that you need … Read more
Every page has a “main query” which is run before the template is loaded. The results of the main query are how WordPress determines what template to load. The standard Loop operates on the data contained in the main query, this is why it seems to just magically “work” without you having to explicitly query … Read more
if your aim is to restrict the category archive to your post_type ‘video’ and to 6 posts per page, do not edit category.php, rather use ‘pre_get_posts’ https://developer.wordpress.org/reference/hooks/pre_get_posts/ example code for your case: add_action( ‘pre_get_posts’, ‘category_post_type_video_custom’ ); function category_post_type_video_custom( $query ) { if ( ! is_admin() && $query->is_main_query() ) { // Not a query for an … Read more
Try this: $paged = get_query_var( ‘paged’ ) ? get_query_var( ‘paged’ ) : 1; $args = array( ‘posts_per_page’ => 5, ‘category’ => 6, ‘order’ => ‘DESC’, ‘paged’ => $paged, ); Currently, you are setting The paged argument to 1.
$args = array( ‘post_type’ => ‘post’, //Specifying the type of posts ‘cat’=> 1, //Selecting post category by ID to show ‘posts_per_page’ => 4, //No. of posts to show ‘paged’ => $paged //For pagination ); //You dont need to use query_posts( $args ); since you are using wp_query $query = new WP_Query( $args ); Use while … Read more
Your code should look like this to exclude duplicate titles <ul> <?php // Initial counter for displayed posts. $counter = 1; // Initial empty array of displayed titles. $titles = []; $portfolio = new WP_Query([ ‘post_status’ => ‘publish’, ‘post_type’ => ‘post’, ‘cat’ => ” . $link1 . ”, // Because we don’t know the number … Read more
the_content echoes post content. It does not return a string that you can manipulate. You need get_the_content() Swap those functions and it should work.
I thing, you should use this code for filter the check box category <?php // cat 42=Laos cat 57=2-4Days <?php $my_query_1 = new WP_query(array(‘category__and’ => array(42,57))); ?> <?php while ($my_query_1->have_posts()) : $my_query_1->the_post(); ?> <a href=”https://wordpress.stackexchange.com/questions/100169/<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”><?php the_title(); ?><?php the_excerpt(); ?></a> <?php endwhile; ?>
Try taking out the ‘paged’ => $paged parameter, as it is simply returning the amount of results for that page, which seems to be set at 10. (You will need to do two separate queries – one for getting the true count, and one for displaying the posts in a paginated format.)