WP Query and date format

For those who experienced the same problem, I finally found a way to do the sort. First I created an extra CMB like this : $cmb->add_field( array( ‘id’ => $prefix . ‘session_gooddatebegin’, ‘type’ => ‘hidden’, ) ); Then I created an action using save_post. If the CPT “session” is being updated, thanks to $update, I … Read more

WP_Query with multiple orderby NOT working with ASC and DESC, what’s wrong?

Your code is invalid (syntax error, missing closing array and semi-colon), and incorrectly nested – if you were to properly indent your code, you’d have something like: $args = array( ‘tag’ => ‘tag-AAA,tag-BBB’, array ( ‘orderby’ => array( ‘title’ => ‘ASC’, ‘post_date’ => ‘DESC’, ) ), ); See how orderby isn’t actually a property of … Read more

Pagination in html table is not working

You should get total and result array separately. Total is to create the page numbers and result array will give you limited data for each pages. Refer the below code. if (isset($_POST[‘list_position’]) && $_POST[‘list_position’] != ‘Select by Position’){ $list_position= $_POST[‘list_position’]; $totalPosition= $wpdb->get_var(“SELECT count(id) FROM resume_databank WHERE position= ‘” . $list_position . “‘ ORDER BY position … Read more

How to exclude a category name from showing?

The function get_the_category is returning you an array of objects (see codex for more info), so if the post has more than one term assigned, then you are just outputting the first one. So I think that doing a foreach loop will solve your problem: foreach ($category as $cat) { if ($cat->slug != ‘featured’) { … Read more

Query only displays one page_id

The p parameter accepts a single integer value, not a string or array of integers. You would want to use the post__in parameter which allows for an array of post id’s. Just a few notes here: You will need to check if you actually have a valid array of post ID’s before passing it to … Read more

WP Query – filtering terms with regex

This is untested, but give it a go. First get a list of the term names in the taxonomy. Then filter the returned array of names against your regex. Then use that filtered array of names for your WP query. // assumes these assignments: // // $taxonomy – the taxonomy name you are querying against … Read more

WP_Query with one category in args shows other categories

Tried your code in a simple page and work correctly. Have you set the “Blog” page as posts page within the “Settings > Reading”? Because in this case the correct code that the cms will load is home.php or index.php according to the template hierarchy https://developer.wordpress.org/files/2014/10/template-hierarchy.png