In case anyone else is looking for this in the future, turns out the best way to do it is by using wp_get_recent_posts
function. Someone knocked up an example that worked great for me:
<?php $args = array( 'numberposts' => '1' );
$recent_post = wp_get_recent_posts( $args );
if (strtotime($recent_post[0]['post_date']) > strtotime('-7 days'))
$class = "new!";
?>
Related Posts:
- Remove current_page_parent nav class from blog index when in CPT
- WordPress Custom Post Types with a page as a parent?
- How to order adjacent posts (prev / next) by custom field value?
- How to model a hierarchy for courses, levels and lessons?
- How make get_next_post() return first post when viewing last one
- Problem excluding category from get_next_post
- specify meta_key / meta_value condition for prev_post_link and next_post_link
- Nav menu of all posts in a custom post type
- Full-Ajax Theme: parseJSON error while building a JSON object from a WordPress custom template
- posts_nav_link on single post template
- Dropdown list of a custom post type
- Highlight nav menu terms
- Custom Taxonomy Breadcrumb Navigation
- Select menu should display categories and the item’s depth
- Why are navigation items saved in the database?
- adding .current* tags to custom post types and taxonomies
- wp_get_nav_menu_items wp-admin/customize.php problem
- current-menu-item not working with custom post type
- Showing Custom Content in a Nav Dropdown
- Hierarchical Custom Posts – Highlighting Current Post in Sub-Menu
- Custom Post Type Navigation on Custom Field
- Add/Remove current_page_parent class
- Twenty Fifteen: Adjacent posts by menu_order [duplicate]
- How can i change the output of posts_nav_link();
- Creating a navigation menu of all posts of a custom post type and their children posts?
- wordpress wp_list_pages help
- Showing up my custom post type in primary navigation
- Paging doesn’t work?
- Hide post navigation if current post is in a category with only one post
- How To Show All Custom Post Types In A Category Instead Of Pagination?
- Losing Nav Active State in Menu
- Custom Post Types in the WordPress Navigation Menu
- How can i automatically add CPT single pages as sub menu items
- How does the ‘the_post_navigation()’ work for CPT’s?
- Displaying Custom Posts
- List All Custom Post Types Posts in Nav Menu Dynamically
- Can’t Get Parent and Child Categories of Custom Taxonomy to Display
- Previous / Next Links For Custom Post Type Sorted By Meta_Value
- Include “Scheduled” (“Future”) Posts in WordPress Post Navigation ( previous_post_link, next_post_link ) for a Specific Custom Post Type
- How to get next post link of child custom post type from parent post and get next post link of parent post from the last child post?
- Manually adding current_page_parent to wp_list_pages()
- Prev/Next Navigation on Single Post Disappeared for Custom Post Type
- How to create a Child & Siblings menu for a custom post type?
- current-post-parent for custom post type
- Adding a nav menu for a custom post type
- Insert a hash into the url of custom posts to make them function as anchors
- Post navigation doesn’t show (in custom template, custom post type, custom query)
- Navigation not working for custom post type pages
- wp_nav_menu doesn’t seem to work on custom post type pages
- Custom nav menu current item custom link problem
- Calling the first & last post by category in custom post type
- Programmatically Split A Post Into Multiple Pages
- next_posts_link returns same content of 1st page
- Custom post type navigation – 404 on page 2
- current_page_item and custom post type?
- Why is Posts page selected when showing single Custom Post Type?
- Navigation links to posts in current term shortcode
- Pagination for Custom Post Type with Multiple Types
- Navigation won’t update to show full path to single post
- get_the_post_navigation not working
- How to Add Custom Taxonomy To Woocommerce Plugin
- Can you have two CPTs with the same permalink structure?
- Custom templates for posts like for pages: page-{id} vs single-{id}
- Alphabetical sorting of custom post type – one letter per page
- Post Via Email to a Custom Post Type
- How to redirect wp-admin/index.php to a custom post type?
- get_post_meta is returning image id
- How many Custom Post Types to register?
- Custom Post type is being ignored in query
- Query custom post type by category slug
- Insert & order custom post types in/as submenu
- How to bulk copy custom fields between custom posts?
- Search / Filter posts on Title/Content OR Tags
- map_meta_cap woes
- WordPress combined with a basic MYSQL table [closed]
- How to get post type and month/year before while loop for date.php file
- School & class blogs: Categorize with categories or custom posts?
- How can I group posts by months and years?
- Displaying a div from an assigned meta_value when on a page
- Custom query – get_the_terms not work
- Programmatically change post visibility on save_post action return a 500
- How to select a template for a custom post type?
- How to show the current category of an article with CPT UI
- How to show custom field on specific custom post type posts only when filled
- duplicate comment section functionality and call it something else for custom post types
- Custom Post type registering as page post type
- Custom taxonomy terms hierarchical navigation
- How to sort by multiple values in a nested WP_Query
- Apply a custom Template to a Custom Post Type from within a plugin
- Different Configuration for the_excerpt()
- Loading a stylesheet on a specific page [duplicate]
- How do I block/redirect ‘?post_type=cpt_name’ urls?
- Simple renaming my custom post type set with a plugin doesn’t work?
- can’t see categories in appearance-menu-categories
- Values inside a custom field to determine which category posts to display
- CPT, Custom User Role and problem with user manager
- Display results from two Custom Post Types in page template
- How to grab data (titles, thumbnails and custom fields) from multiple posts to populate a new array efficiently?
- register_term_meta not working
- show posts under custom post type with same autj