query_posts works while get_posts doesn’t

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

Pagination in category.php not functioning

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

prevent display duplicate titles on main page

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

Filter posts by multiple checkbox categories

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; ?>

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