Hook to main query with filters based on custom fields

Have a look at the format of a meta_query in WP_Query. $meta_query = array( array( ‘key’ => ‘price’, ‘value’ => array( 500, 1000 ), ‘type’ => ‘numeric’, ‘compare’ => ‘BETWEEN’ ) ); $query->set( ‘meta_query’, $meta_query );

Modifying a Loop to Show More

Have you tried setting $count equal to 4 on line 8? Like this: <div class=”col”> <?php gab_dynamic_sidebar(‘Subnews1’);?> <?php $postnr = of_get_option(‘of_wn_nr8’) + of_get_option(‘of_wn_nr8a’); if (intval($postnr) > 0 ) { ?> <span class=”catname”><a href=”https://wordpress.stackexchange.com/questions/87543/<?php echo get_category_link(of_get_option(“of_wn_cat8′));?>”><?php echo get_cat_name(of_get_option(‘of_wn_cat8’)); ?></a></span> <?php $count = 4; // etc

Filter Category Loop Dynamically

You are opening a php tag inside an open php tag so you are actually calling this whole string: <?php global $current_user; if ( isset($current_user) ) {echo $current_user->user_login;}?> as a category and you echo it out (wrongly) which is not passing ia as a perameter to query_posts move it outside the query_posts call: global $current_user; … Read more

new custom theme – posts displaying on top of one another

You have closed div having content class inside if statement which causes to break nested markup, instead close it outside if statement as following. <?php /* Template Name: Blog */ ?> <?php get_header();?> <div id=”blog-container”> <div class=”content”> <?php get_sidebar( ‘blog’);?> <?php if(have_posts()) : while(have_posts()) : the_post(”); ?> <div class=”meta”> <h3><a href=”https://wordpress.stackexchange.com/questions/89410/<?php the_permalink(); ?>”><?php the_title(); ?></h3> … Read more

Adding a featured image to a foreach WordPress loop

This is the syntax problem: $content .= ‘<img src=”‘.($post->the_post_thumbnail->small).'” />’; The the_post_thumbnail() function is not part of the $post object, and would print, rather than return, the post thumbnail, even if that method would work. Try using get_the_post_thumbnail() instead: $thumbnail = get_the_post_thumbnail( $post->ID, ‘small’ ); Note that this function returns the fully formed <img> tag … Read more

Collect Data from NEXT item while in loop

As you posted no code and little in the way of exactly what criteria you are using, I can’t really writ functioning code but inside your Loop try: var_dump($posts[$wp_query->current_post -1]->post_title); That is, $posts[$wp_query->current_post -1] is the previous post. You can change -1 to plus or minus whatever value you want but the math cannot result … Read more

static page with multiple loops breaks post pagination

You aren’t setting the $paged variable, at least not in the code posted. Per the Codex, you need to do something like this: $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; … before trying to use the $paged variable. That is, it needs to come before this line: $wp_query->query(array(‘post_type’=>’post’,’post_status’=>’publish’,’showposts’>3,’paged’=>$paged)); Also, side note, what is this– php … Read more

How to break up php code to avoid echo

You have an extra “}”, there must be two such braces for two for each loops. Also you need to have endif; statement at end after endwhile. Parsing error may be due to extra “}”. Please try below code and let us know if it works. <?php $custom_terms = get_terms(‘videoscategory’); $other_custom_terms = get_terms(‘product_category’); foreach ($custom_terms … Read more