order one custom post type by modified time of another post type
order one custom post type by modified time of another post type
order one custom post type by modified time of another post type
Thank you to Tom J Nowell for pointing me to using WP_Query instead of get_posts. With WP_Query you have the entire WP_Query object to reference. So something like the following gives the actual mysql query of the args I was using. // these same args also worked with get_posts() $args = array( ‘post_type’ => ‘post’, … Read more
You could adapt get_post_acestors(), and write a similar function for comments. Here is an example that returns the top comment’s id or false. Not tested! function get_root_comment( $comment_id ) { $comment = get_comment( $comment_id ); if ( ! $comment || empty( $comment->comment_parent ) || $comment->comment_parent == $comment_id ) { return false; } $ancestors = []; … Read more
Protect sequence of pages with same password for each of two groups of users
Ordering by a metadata subfield in WordPress?
Maintaining Queries in URL
When you run a search (you call it a query) WordPress must use its DBMS (MariaDB / MySQL) to examine the entire text of every post, page, and user on your site. That takes time. There are some plugins out there to make search more efficient, but it is still work for your site to … Read more
Order posts by custom field DATE value
I would use the built in API like Rarst mentioned. You could do something like this: $just_seven = new WP_Query( array( ‘category__in’ => array( 7 ), ‘category__not_in’ => array( 10 ) ) ); You would then have those items in $just_seven->posts. However, if you MUST use a direct SQL statement, I’d suggest using INNER JOIN … Read more
The asker refused to post his solution as answer, so I took the liberty to get this question out of our growing Unanswered Questions list … <?php $logo = get_post_meta($post->ID, ‘_lm_comm_logo’, true); $map = get_post_meta($post->ID, ‘_lm_comm_map’, true); $args = array( ‘numberposts’ => -1, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, … Read more