Hot answers tagged

4

I believe that you can achieve this effect by grouping the query by author ID, which will require a filter(mostly cribbed from the Codex): function my_posts_groupby($groupby) { global $wpdb; $groupby = "{$wpdb->posts}.post_author"; return $groupby; } add_filter( 'posts_groupby', 'my_posts_groupby' ); If you have less than 8 authors, however,...


3

I have taken a look and to me it seems that you are not consequent with dates when it is about publishing. (yes I understand that this is probably a new site and you have added all postings at one moment, but just 'act' as it was posted on those days/years.) Take a look at the publishing dates of the postings. I would change ALL those publishing dates to ...


2

This is a default feature which by default is set not to show the post date. Here is the part of the code responsible to show/hide the post date <?php if ( $show_date ) : ?> <span class="post-date"><?php echo get_the_date(); ?></span> <?php endif; ?> To enable the post date, just check the Display post date? checkbox ...


1

get_category_link() accept the category ID or object and you are passing the post ID. the_category() accept Separator as a first parameter to separate multiple categories and again you are passing post ID. You can use get_the_category to get all the categories and then display one of category information. Example:- $all_post_categories = get_the_category($...


1

I'm not sure what you're doing with the above script, but here are some random suggestions: Avoid using the root user, for security reasons create another database user with less powers. Avoid using deprecated mysql_* calls. Use WP_Query() or get_posts() instead of hardcoded SQL queries. Use global $wpdb object if you really must use hardcoded SQL ...


1

You can do it easily with WP_Query: $args = array( 'date_query' => array( 'relation' => 'OR', array( 'column' => 'post_date', 'after' => '-2 days' ), array( 'column' => 'post_modified', 'after' => '-2 days' ) ) ); $query = new WP_Query( ...


1

If you want both posts that have and do not have a meta key, you need an OR relation meta query to select both posts with key and those where it does not exist. $args = array( 'meta_query' => array( 'relation' => 'OR', array( 'key' => '_post_like_count', 'compare' => 'EXISTS' ), array( ...


1

HERE IS THE SOLUTION /** * Extend Recent Posts Widget * * Adds different formatting to the default WordPress Recent Posts Widget */ Class My_Recent_Posts_Widget extends WP_Widget_Recent_Posts { function widget($args, $instance) { if ( ! isset( $args['widget_id'] ) ) { $args['widget_id'] = $this->id; ...



Only top voted, non community-wiki answers of a minimum length are eligible