Displaying year once in category.php [duplicate]

Create your query for the category, and order by date $q = new WP_Query(‘category_name=acategory&orderby=date&order=DESC’); After that, while looping posts, save the year in a helper variable, shoing it only when changed: $year = 0; if ( $q->have_posts() ) : while ( $q->have_posts() ) : $q->the_post(); $post_year = (int) get_the_time(‘Y’); if ( $post_year !== (int) $year … Read more

Archive with months of current year only

I left the plugin for what it was and finally figured it out with help of one of the answers in the other thread I’ve mentioned. The code below did what I needed. function get_posts_grouped_by_month( $year = null ) { if ( $year == null ) { $year = date(‘Y’); } $months = range(1,12); $posts … Read more

First post article different on Archives template

Just point to the first element of your list of articles using CSS pseudo class like this: PS. I’m so used to less that I’m gonna give you the .less syntax, but you can figure it out on your own right? .container-with-your-posts { > .post-container { &:first-child { h1 { your styles for the title … Read more

Problem with multiple loops in wordpress theme

The proper way to set up a secondary query, using your example code. Instead of this: $posts = get_posts(‘numberposts=1&order=DESC&orderby=post_date&category=’.get_cat_ID( ‘سیاست’ )); Do this: // Query args $custom_cat_args = array( ‘posts_per_page’ => 1, ‘order’ => ‘DESC’, ‘orderby’ => ‘post_date’, ‘cat’ => get_cat_ID( ‘سیاست’ ) ); // Instantiate query $custom_cat_query = new WP_Query( $custom_cat_args ); // Instantiate … Read more

Need to have an archive widget which organizes and displays a custom post type using a custom date field

Yep. You can add a meta_query parameter to methods that query posts, such as WP_Query. This one below gets a custom post type between two dates (which are custom fields created by ‘advanced custom fields’ plugin) and sorts on one of these dates: $args = array( ‘post_type’ => ‘event’, ‘posts_per_page’ => ‘-1’, ‘post_status’ => array( … Read more

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