Same query in category.php and in function.php, but different result

Found the answer – the query on the category page had post_status=”publish” by default and the query in the function.php had post_status=”publish” OR post_status=”future” OR post_status=”draft” OR post_status=”pending” as default, so the solution was to be more explicit in the $args and add ‘post_status’ => ‘publish’.

Are there any best practices for creating a Like/Favourite feature in WordPress using custom MySQL tables and without any plugins?

Using WordPress’s wp_postmeta will help you a lot, instead of creating a new table. Functions like get_post_meta(), update_post_meta(), add_post_meta() etc, are readily available for use. All you need is to create a meta_key (which in this case will be wp_likes) and the meta_value (number of likes will be stored), which can be easily retrieved using … Read more

WordPress search form and search result through ACF field in custom taxonomy

This should hopefully help you on your way, although I’ve not fully tested it… The basic search form here which will load the site_url() with appended search query string. You should change this to better reflect your site layout such as <?php site_url( ‘search’ ); ?> (‘http://website.com/search‘). Place the Results page code within the results … Read more

How to fix pagination for custom loops?

The Problem By default, in any given context, WordPress uses the main query to determine pagination. The main query object is stored in the $wp_query global, which is also used to output the main query loop: if ( have_posts() ) : while ( have_posts() ) : the_post(); When you use a custom query, you create … Read more

how to show more than 1 post into three columns query

I haven’t tested it but see if that works Assign values to variables before begining of while loop $c = 1; $counter = 5; Change your all $couter if conditions if($counter == 1) if($counter == 2) if($counter == 3) into this respectively if($counter % $c==1 || $counter % $c==2) if($counter % $c==3) if($counter % $c==4 … Read more

Query not returning child posts for any parent post ID

It seems the problem is that for parent/child relationships, I’m using the Toolset Types plugin, which stores the relationships as fields rather than how WordPress normally thinks of them. This means that when WordPress looks at a post ID, it doesn’t see the child relationships that the plugin does. To get around this, I used … Read more

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