Get id of category from drop down menu

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

Show the title of the latest post by author

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

Function to check if author has posted within the last x days

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

How to get posts by content?

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

How to add paging to query

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’ => __(‘&laquo;’), ‘next_text’ => __(‘&raquo;’), ‘total’ => ceil($total / $items_per_page), ‘current’ => $page ));

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