Tag Info

New answers tagged

1

Can someone please explain how "$posts" is used within the loop? It isn't. It returns the array of queried posts , but it is insignificant and not used at all: if you remove it than the code works the same: global $query_string; query_posts($query_string.'&cat=-9'); if (have_posts()) : while (have_posts()) : the_post(); ... endwhile; endif; ...


-3

**The default syntax for showposts is-** <?php $query = new WP_Query (array( 'showposts' => 5, ) ); while ($query->have_posts()): $query->the_post(); ?> <li> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> ...


0

I modify wordpress query from functions.php: //for "IS_PAGE" conditions, pre_get_posts doesnt work (it's WORDPRESS behaviour) //so, inside `add_action('wp....` use `add_filter(posts_where.....` OR modify "PAGE" query directly into template file add_action('pre_get_posts','myf88');function myf88($query) { if ( !is_admin() && ...


0

i use pre_get_posts. example: add_action('pre_get_posts','search_filterr');function search_filterr($query) { if ( !is_admin() && $query->is_main_query() ) { if ( $query->is_search ) { //$query->is_category or etc...except is_page() $arrs[]='post'; $arrs[]='page'; $arrs[]='my_carss'; ...


0

I guess you have 4 different news, you want display first news use large image of each page and the news of large image is different others, right? If you right, the following code, maybe work for you. <?php $b=1; $args = array( 'tax_query' => array( array( 'taxonomy' => 'gens', 'field' => 'slug', ...


0

I don't know why have you put $b%4==1 condition. You can simply check for $b==1.And one more thing I would suggest is to use if and else both.So code would be something like this: <?php $b=1; $args = array( 'tax_query' => array( array( 'taxonomy' => 'gens', 'field' => 'slug', ...


0

First, do not query_posts; use WP Query instead. That being said, I assume that pce_monday_open is lower than pce_monday_close and that you want posts between pce_monday_open and pce_monday_close, so I think your comparison logic is wrong. Also, you may need to set the relationship between the two meta query arrays: $pce_arg = array( 'cat' => 6, ...


2

post is not a valid value for orderby parameter neither DESC. You can choose any of these values. Also, you should stop using query_post. <?php $args = array( 'post_type' => 'ranking', 'orderby' => 'menu_order', 'order' => 'DESC', ...


0

Save value in database like : 'enddate' => date('Y-m-d'); Generate meta query like : A. Condition : $conArr[0] = array ( 'key'=> 'enddate', 'value' => date('Y-m-d'), 'compare' => '>=', ); B. Query: $args = array( 'meta_query'=>$conArr , 'post_type'=>'tournament', 'orderby' => 'meta_value_num', ) ...



Top 50 recent answers are included