Filter Query Post by Custom Fields(by date)

As already said, your query arguments are slightly off – meta_query should be an array of arrays: $query = new WP_Query( array( ‘category_name’ => ‘events’, ‘order’ => ‘DESC’, ‘orderby’ => ‘meta_value’, ‘meta_query’ => array( array( ‘key’ => ‘start_date’, ‘value’ => strtotime( ‘today’ ), ‘compare’ => ‘>=’, ‘type’ => ‘UNSIGNED’, // Ensure MySQL treats the value … Read more

Render a loop in Timber (twig for WordPress)

@Xroad, here’s the simplest way. Things can get a bit more complicated depending on the specifics, but this is the most straightforward way: $query = get_posts(array(‘post_type’ => ‘lexique’,’posts_per_page’ => -1)); $by_letter = array(); while( $query->have_posts() ) { $query->the_post(); global $post; $letter = substr($post->post_name, 0, 1); if ( ! isset($by_letter[$letter]) ) $by_letter[$letter] = array(); $by_letter[$letter][] = … Read more

WordPress pagination returns the same posts

You must change $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; To the following : $paged = (get_query_var(‘page’)) ? get_query_var(‘page’) : 1; There is a difference in page and paged for a static front page, You may find your Answer here : https://developer.wordpress.org/reference/classes/wp_query/#pagination-parameters Keep Posted

Change from all posts to specific categories post on main page?

Your syntax is wrong, change: query_posts( array( ‘post_type’ => array( ‘post’, $include_reviews, $include_screenshots, $include_videos ), ‘paged’ => $paged ) ); to: query_posts( array( ‘tax_query’ => array( array( ‘taxonomy’ => ‘category’, ‘field’ => ‘slug’, ‘terms’ => array( $include_reviews, $include_screenshots, $include_videos ) )), ‘paged’ => $paged, ‘post_type’ => ‘post’) );

Lots of SQL queries

Delete post/page revisions and that will reduce queries as well as the overall size of the DB. Run this in phpmyadmin (backup the DB first): DELETE a,b,c FROM wp_posts a LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id) LEFT JOIN wp_postmeta c ON (a.ID = c.post_id) WHERE a.post_type=”revision” Change table prefix above if needed. And … Read more

Sort posts with multiple meta_keys

WP_Query supports multiple values for the orderby argument (see the example from that link on the Codex. I don’t know if query_posts() does as well, but I suspect the pre_get_posts filter does, in which case you can replace query_posts() with that (which is the new “best practice” anyway).

How to exclude certain portfolios from a loop

so I am thinking your $arg would be: $args = array( ‘numberposts’ => $portfolio_items, ‘order’ => $portfolio_sort, ‘orderby’ => ‘date’, ‘post_type’ => array(‘portfolios’), ‘offset’ => $offset, ‘exclude’ => ‘1,2’, ); And that would exclude post 1 and 2. But a better option that you should do, is to just create a featured category for your … Read more

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