How to display all posts with today’s same month and day only?

You can achieve this with the date_query parameters added in version 3.7. To modify the main query on your posts page before it is run and apply the date_query parameters, we use the pre_get_posts action: function historical_posts_list( $query ){ if( $query->is_home() && $query->is_main_query() ){ $date_query = array( array( ‘month’ => date( ‘n’, current_time( ‘timestamp’ ) … Read more

How to show more than 5 posts?

I think you could use the posts_per_page argument in your get_posts query: $args = array( ‘child_of’ => 1 ); $categories = get_categories( $args ); foreach ($categories as $category) { echo ‘<li><a>’.$category->name.'</a>’; echo ‘<ul>’; $posts_args = array( ‘posts_per_page’ => 9, ‘category’ => $category->term_id ); foreach (get_posts($posts_args) as $post) { setup_postdata( $post ); echo ‘<li><a href=”‘.get_permalink($post->ID).'”>’.get_the_title().'</a></li>’; } … Read more

Query all posts and not repeat the same tag

You can try something like this: <?php $tags_array = get_tags(); $news_query = new WP_Query; foreach ( $tags_array as $tags ) : $news_query->query( array( ‘cat’ => $tags->term_id, ‘posts_per_page’ => 1, ‘no_found_rows’ => true, ‘ignore_sticky_posts’ => true, )); ?> <h2><?php echo esc_html( $tags->name ) ?></h2> <?php while ( $news_query->have_posts() ) : $news_query->the_post() ?> <div class=”post”> <?php the_title() … Read more

$wpdb->query() vs. $wpdb->get_results() vs. phpMyAdmin

The difference is what is returned. The WPDB query() method returns true for CREATE, ALTER, TRUNCATE and DROP queries, an integer of how many results for all other queries, or simply false if if there’s an error. The WPDB get_results() method actually returns the entire result of the query (like you would get running the … Read more

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