Maybe a bit less hacky:
$months = array();
while(....){
list($month, $year) = explode("https://wordpress.stackexchange.com/", get_the_date('n/y')); // eg. 7/11
if(in_array($month, $months)) continue; // skip
$months[] = $month;
echo '<li><a href="'.get_month_link($month, $year).'">'.get_the_date('F Y').'</a></li>';
}
If you’re only getting 6 posts and you don’t need pagination that I guess it’s OK to go this way.
Otherwise you need to build your own SQL query to pull out only one post for each month…
You could also try to make 6 queries for each month, like:
$january_posts = new WP_Query('monthnum=1&posts_per_page=1'));
Related Posts:
- Two queries for a WP_User_Query search work perfectly apart, but not together
- Include a custom field in mysql query
- If Elseif Query
- How to update custom fields using the wp_insert_post() function?
- Adding custom input for data attribute in insert media modal
- The correct method to pass query vars in AJAX using ajaxurl
- Alter query on edit.php
- If Custom Field is empty don’t display div
- Custom Meta Field – Youtube embed
- How to find objects by terms
- How to create a WP_Query to search the Title or Tag?
- Print html when custom field has value inside while loop
- Update WordPress Custom Field with AJAX on cached page
- How to get user by display_name with WP_User_Query
- How to Explode a Textarea Field and Echo each line separately, wrapped with HTML
- how to increase custom post value by one most efficiently?
- How to get to a specific position in wp_query?
- Multiple choice in a custom taxonomy
- Get all user meta by meta key instead of ID
- Sum custom field values of particular taxonomy
- Importing hard coded custom field into acf field
- Get stock by custom meta field on all Woocommerce variable products
- Passing the custom field values in the wp_get_current_user array function
- mysql query from wordpress page using custom table
- Firing schema via code in functions.php doesn’t work
- How can I add extra word in permalink when someone click download button?
- Seach custom post type posts only by meta fields?
- How to pre populate a form field with a link of a current user’s author profile?
- Trying to get a PHP variable defined in a custom post into a javascript file. Null value. Using wp_localize_script
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- conditional logic for front-end custom field edits
- register_taxonomy() take much queries
- Automatic Shortcode Creation with Custom Fields [closed]
- Custom field values to taxonomy terms
- Which PHP page is the Default Posts Page
- Non-Closing PHP Query in WordPress Loop
- How to check if a PHP string is different than meta field?
- Display custom field on 404 page outside loop
- How to show/hide php table rows based on the content of custom fields
- working with term_relationships table
- how to get serialized post meta
- Hide Heading if ACF Field is empty
- How to show meta value code HTML after x paragraph
- Issue with custom loop in Archive page
- Creating an image from a custom field
- User Meta Value not echoing despite Var_Dump Showing correct string
- Shortcode to pull posts
- Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
- Output custom text field as unordered list
- Conditional featured image with youtube thumbnail
- Order a WP_Query by meta value where the value is an array
- Add a custom class to the body tag using custom fields
- Undefined variable: row?
- Change Query Arguments (filter) with jQuery/Ajax or PHP?
- SQL error with custom query
- WordPress Conditional / Multiple Taxonomy Query
- How can I modify this code to make the search box include tags and meta
- Woocommerce Custom Meta Boxes- How to only display if they actually have content
- Updating Metadata with Shortcode
- How do you save the values from custom fields to a products data
- Advanced Query posts
- Is it possible to update the dataset using update_post_meta
- Setting up a cron job to auto update a custom field
- Inserting a class on before_widget if checkbox is checked
- What is the correct way to search 3 custom fields only in WordPress?
- How do I get the value of a current user’s custom field?
- Trying to retrieve meta values from three different meta keys and display in rows
- WP post meta – for loop inside for loop
- Store custom field’s multiple values in one user meta key
- Get field in readable word
- WooCommerce multiple custom fields code
- Let user select the number of posts shown per page jquery error
- Query doesn’t display text data with apostrophes
- How to query a staging database?
- WP_query meta_query slow with OR and DATES
- How to make a parent page for author.php?
- Get meta_query value by user meta array
- meta field for numerous links
- Custom fields changes the formatting of metabox input
- divide custom field values in div every two values
- Showing custom field contents without listing description
- How to exclude post from being queried based on custom meta value
- Check if values exists DB
- Trying to exclude posts from a category on the home page
- How to link a word comprised of a custom field with another?
- I want Page titles and excerpts to show up on home.php in certain order
- Posts sortable column not sorting properly for custom field numbers
- The search engine of my website finds only posts and not pages, how can I solve this problem?
- Hide empty categories from get_categories
- Search result page – display values from the result’s metaboxes
- Query Concatenation
- ACF Date fileds to Age Convert [closed]
- Save custom field value to variable for conditional – why is this not working? [closed]
- Can WordPress support Website (19GB database) Should I move Our WordPress Website to a custom one using Laravel or any other PHP framework?
- How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
- Three different queries on same page
- I want to show image from custom field image on my custom page template
- Custom Admin Menu Report for Specific User ID
- Exclude a category ID from the following function
- ACF number less than comparison not working