posts order by title second word

The simplest method may be to just save titles as last name / first name, then they will naturally sort. You can then reverse the title when you output it in the template. Your attempt to modify the orderby query var is fundamentally flawed. Order is created by MySQL, which doesn’t understand PHP, and can’t … Read more

Filtering WP_Query result by category

The category parameters of WP_Query does not have this type of logic. category__and and category__in does not return posts in child categories of the set categories. I would suggest that you make use of the tax_query parameters in WP_Query, which have the logic you are looking for. The relation parameter has two possible values, AND … Read more

Where to use $post global variable?

The $post global is set by $wp_query->the_post(). As $post is set by the main query and the fact that templates are set within the global variable scope, it is available throughout the template, so there is no need to explicitly calling the $post global when you are within the specified template as the WP_Post objects … Read more

Get the post thumbnail with wp_query

If you are using this inside the loop of your WP_Query then why are you providing the Post ID parameter in functions. You don’t need to do that. So your code will become this. <?php echo ‘<h2><a href=”‘ . get_permalink() . ‘”>’ . get_the_title() . ‘</a></h2>’ . get_the_post_thumbnail( get_the_ID(), ‘full’ ); ?> And please read … Read more

Multiple search queries on one page

You can use pre_get_posts to modify the main query, but you will need to create new queries for the other searches. Use get_query_var(‘s’) to get the search terms and create new WP_Query objects to perform your search. Without more information it is hard to provide much more detail to the answer.

Get all remaining posts after a particular post id

You can try this: $query = new WP_Query( [ ‘wpse_pid’ => 100, // Our custom post id argument ‘wpse_compare’ => ‘>’, // Out custom compare argument (<,>,<=,>=,!=,<>) ‘posts_per_page’ => 100, // Modify this to your needs ] ); where we use the following plugin to support these two custom arguments: <?php /** * Plugin Name: … Read more

Filter by title content and meta key at the same time

Such condition is impossible to express in current WP API. You can use search for title/content matches and meta query for LIKE matches on post meta, but there is no way to establish OR relationship between the two. The closest API way would be two–stage query where you query IDs for two sets of results … Read more

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