How to order posts by modified date without using ‘query_posts’?

You haven’t specified where you want this alteration to apply to so I’ve applied it to just the home page. You may alter to fit where this filter applies to: <?php function wpse10691_alter_query( $query ) { if ( $query->is_main_query() && ( $query->is_home() || $query->is_search() || $query->is_archive() ) ) { $query->set( ‘orderby’, ‘modified’ ); $query->set( ‘order’, … Read more

Passing a varible from jQuery to PHP

First, don’t use query_posts. Second… I think this can be done with AJAX but is there a more simple method and give me a clean URL? PHP runs on the server. Items are “clicked” on the client machine. The only way to pass that “clicked” value back to PHP is via AJAX. Within a WordPress … Read more

WordPress Posts Out Of Order after 3.1 Update

Simply add orderby to your query_posts <?php query_posts($query_string . ‘&cat=-4&orderby=date&order=DESC’); ?> Update try: global $wp_query; $args = array_merge( $wp_query->query, array(‘cat’ => -4,’orderby’ => ‘date’,’order’ => ‘ASC’)); query_posts( $args ); and if you still get the same change ASC to DESC.

Multiple posts with one loop iteration

Ultimately, this question is off-topic, because the solution has nothing to do with WordPress. Outputting posts in a grid pattern is an HTML/CSS issue, and the best-practice solutions don’t involve putting every three posts inside a separate containing <div>. Even so, you can do what you want to do, using PHP (which, technically speaking, still … Read more

Posts per Page on custom Taxonomy Template

number_posts is not a valid parameter in pre_get_posts, you should be using posts_per_page You should also include a check (!is_admin()) in your query to check whether you are on the front end or back end as pre_get_posts alters back end queries as well Rewrite your code to the following: add_action( ‘pre_get_posts’, function ( $query ) … Read more

How do I create my own nested meta_query using posts_where / posts_join?

Here is a rough outline of how you’d go about making a UNION work with WP_Query. add_filter( ‘posts_request’, function ($clauses) { $clauses = str_replace(‘SQL_CALC_FOUND_ROWS’,”,$clauses,$scfr); $scfr = (0 < $scfr) : ‘SQL_CALC_FOUND_ROWS’ : ”; $clause2 = $clauses; // manipulate this return “SELECT {$scfr} u.* FROM (({$clauses}) UNION ({$clause2})) as u”; }, 1, 2 ); Set up … Read more

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