get_posts returning empty array
Try “post_type” => array(‘carellcars’, ‘ccf’, ‘attachment’),
Try “post_type” => array(‘carellcars’, ‘ccf’, ‘attachment’),
You’re on the right track with using a form, the only thing you’re missing, you have to submit what you have selected. For example like this: <form method=”GET” action=””> <div> <?php $select = wp_dropdown_categories(‘show_option_none=Select category&orderby=name&echo=0’); $select = preg_replace(“#<select([^>]*)>#”, “<select$1 onchange=”return this.form.submit()”>”, $select); echo $select; ?> <noscript> <div> <input type=”submit” value=”View” /> </div> </noscript> </div> </form> … Read more
You can get the latest post of an author adding the following code to your function: $latest_post = get_posts( array( ‘author’ => $id, ‘orderby’ => ‘date’, ‘numberposts’ => 1 )); // Since get_posts() returns an array, but we know we only // need one element, let’s just get the element we need. $latest_post = $latest_post[0]; … Read more
Yes, it is possible and it is pretty small change in your code… get_posts() uses WP_Query, so you can use all params from this list: https://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters So here’s your code after changes: $args = array( ‘post_type’ => ‘your_custom_post_type’, ‘author’ => get_current_user_id(), ‘date_query’ => array( array( ‘after’ => ‘- X days’, // <- change X to … Read more
You have to extend the db query to search in the post_content column. There is a filter: ‘posts_where’ you can use. I would write a simple wrapper for get_posts() to extends its arguments an run the filter once. Example: class T5_Posts_By_Content { protected static $content=””; protected static $like = TRUE; /** * Mapper for get_posts() … Read more
Rather than using next_posts_link and previous_posts_link, try paginate_links. It lets you specify the current page and total page count. For example: echo paginate_links( array( ‘base’ => add_query_arg( ‘cpage’, ‘%#%’ ), ‘format’ => ”, ‘prev_text’ => __(‘«’), ‘next_text’ => __(‘»’), ‘total’ => ceil($total / $items_per_page), ‘current’ => $page ));
You can still do this with the 3.5 uploader. Click the Add Media button Click the Insert Media Tab (top left) Click the Media Library Tab (top center under Insert Media heading) Click the Dropdown SELECT box and select Uploaded To This Page Drag and drop the thumbnails to reorder them as you were able … Read more
I would try use ‘perm’ => ‘readable’ in your query arguments to make sure WP_Query runs a permissions check.
To check if the query itself is slow or anything else slows it down, try running your query directly in the database, and have a look at how long it takes there. <?php echo $GLOBALS[‘wp_query’]->request; ?> This shows you the latest Query that WordPress ran in your database. If the query is really slow in … Read more
I am not sure, if this is the most efficient option or not, but I have doen it in following way: I have stored 5 separate query using get_posts and stored them in a single array I had to flatten the array, since it was multidimensional. Then used usort using post_date to get the latest … Read more