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

Can’t see custom field after the Loop [closed]

When you output your get_posts results and do this: setup_postdata($post); You overwrite the original value of $post which the_field uses to fetch the field data. It’s trying to get that field belonging to the last post in $products_mono_posts instead of the page that the field actually belongs to. After running custom queries where the value … Read more

Trouble preventing duplicate posts between 2 loops on homepage

As usual with multiple loops, one of which is main loop, the issue is messy. What it looks like is happening: Secondary loop runs and deals with some posts. Main loop runs and deals with some posts. What is actually happening: WordPress core is loaded. Posts are queried for main loop. Template file is decided … Read more

get_posts and wp_autop (remove filter)

You could make your own excerpt function: function wpse125086_custom_strip_tags_excerpt() { global $post; $p_obj = get_post($post->ID); $p_exp = $p_obj->post_excerpt; $p_exp = apply_filters(‘the_excerpt’, $p_exp); $un_p = array(“<p>”, “</p>”); $p_exp = str_replace($un_p, “”, $p_exp); echo $pcont; } But generally I’m thinking instead of transforming to get_posts() it might be better to go with WP_Query. In this case the … Read more

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