How about this? (Add to your theme’s functions.php file, or to a plugin.)
function new_post_alert() {
global $post;
$ageunix = get_the_time( 'U' );
$days_old_in_seconds = time() - $ageunix;
$days_old = $days_old_in_seconds / 86400;
$post_type = get_post_type();
if ( ( $days_old < 3 ) && ( 'news' === $post_type ) ) { ?>
<script type="text/javascript">
jQuery(document).ready(function($){
$("#notification").addClass("notification-highlight");
//alert('new!');
});
</script><?php
}
}
add_action( 'wp_footer', 'new_post_alert' );
Related Posts:
- Custom Post Type Archives by Year & Month?
- Set post date before 1970
- Reducing the use of global $post
- How to order posts of a custom post type by date DESC in dashboard Admin?
- WP_Query() show posts that end later than today
- Uploading DB to server from local is not matching the post dates
- Permalinks using event date (year & month) instead of publication date
- How to sort CPT by custom meta value (date), and return posts month by month
- Date query for a custom meta field
- Custom Post Types – How to include custom fields
- How to make an archive page displaying posts in a date range
- Query current and future events, ordered by begin date
- Displaying custom posts only if custom meta box’s date is not expired
- Multisite Global Custom Posts
- Get the next event using date_query
- get_queried_object error How to show post count by month in the taxonomy page
- Custom Post Type Events Archive Grouped By Month
- query_posts with a custom post type, a meta_query and sorting by post date?
- How does the $post_type global variable work?
- Using global $post; to get featured image for custom post via WP_Query
- Default sort on admin columns with meta date hides draft posts with empty date value
- WP_Query most viewed posts, in multiple Post Types, last 30 days, excluding a specific taxonomy term
- How to make global post work with custom post type?
- Post count by month of taxonmy term
- Assign External Database Queries to Global Variables and Make Them Accessible
- Meta Query posts not showing on ending date of custom field
- Use the same date-based permalink structure for all post types
- How to order posts of a custom post type by date DESC in dashboard Admin?
- Order post by date with ACF
- Global $post shows null in some of my custom post types archive pages
- Does WP have a global of $id?
- Sort custom post type by most current date picker
- I am trying to get cutom post cout by month of current taxonmy term
- How to display a WordPress Custom Field only on a specific day of the week?
- WordPress giving a 404 page when passing a year argument different than the current year
- Using WP meta query to show custom post types by a start and finish date
- Why does my URL keep returning 404 error code?
- Problem with date comparison for custom fields
- How to sort WP_Query by a custom text field (written as a date dd/mm/yyyy)
- How to set post date in post_type so that it’s same as latest post in category
- Display post count for a specific month
- Compare ACF Date field to today or yesterday
- get_queried_object not work in taxonomy page
- Want to display my custom date archive to date.php but dont know how
- Pre_get_posts comparison with custom field doesn’t work
- Display year value before a set of posts
- date archive future posts
- Get month and day from a Date Picker custom field
- Loop posts in a table ordered by a custom field value
- Popup panel is only displaying 1 entry ignoring all others
- group posts by month/date ignore years
- How to get past and upcoming post by defining date in custom field?
- How to display custom post type ordered by a custom field date
- Change custom post status to draft before today
- How to save an integer as taxonomy term?
- Generate daily archive whenever any post type is added
- Create a list of months based posts
- How to randomize published date for WordPress custom post type
- ACF Field to set Publish Date – Post Duplication upon Update
- Is it possible to specify a time interval (from, to) in ACF with date picker, or other custom field?
- Order Wp Query by earliest of 3 dates meta query
- WP_Query() displaying past post / event
- How to display *block number* instead *date value* on WordPress posts?
- Many CPT is conflicting of the custom date
- uploading problem of wordpress theme
- Excluding a Custom Post Type with a specific tag using pre_get_posts
- Custom Post Type Link added to menu won’t show in frontend
- show all custom posts types in home page
- List of users that clicked a ‘Join’ button at single post
- Taxonomy archive 404ing (not term archive)
- Pagination doesn’t function properly for archive of a custom post type set as the front page
- Variable not working in WP_Query
- WP_query – Filter by tax_query and meta_query using multiple select
- Display an authors post on a single page only when they are logged in
- How to group navigation items in the admin panel
- Hide meta box for everything BUT a certain custom post type
- Include php on a specific page template
- Create Array from custom post type to display a slider
- what custom post type this archive belongs to?
- Setting Post Title via Meta Data returns Auto-draft
- Tags not working in my custom post type
- Custom post-type metabox position
- wp_trash_post action hook with custom post type
- Not sure why this template for custom post type posts isn’t displaying anything. What’s missing?
- What’s an efficient way to change the post status of many posts at once?
- Use Pages for Custom Post Type
- Return the name of the post type
- I can’t access custom taxonomy page listing
- Is it possible to load a different sidebar in single.php based on a meta_query filter?
- How to have permalink like domain.com/term/postname?
- List Posts By Custom Taxonomy
- Can variables be used to rewrite a Custom Post Type permalink? [duplicate]
- Creating two loops based on different logic
- How to Echo Metadata Value in Currency Format
- Issue on Working with Metabox – Checkbox to enable Sale Items
- Filter posts by tax (dropdown) and meta value
- How do I amend form data before it is saved for a custom post type
- Archive-posttype.php isn’t loaded
- List of all entries of custom-post-type: Add year-parameter?
- Wp Query with multiple custom tag(taxonomy) by get the terms