You can check the post type with get_post_type()
. You only want to display the content if the value is post
:
function wpb_last_updated_date( $content ) {
$u_time = get_the_time( 'U' );
$u_modified_time = get_the_modified_time( 'U' );
if ( get_post_type() === 'post' ) {
if ( $u_modified_time >= $u_time + 86400) {
$updated_date = get_the_modified_time( 'F jS, Y' );
$updated_time = get_the_modified_time( 'h:i a' );
$custom_content="<p class="last-updated">Last updated on ". $updated_date . ' at '. $updated_time .'</p>';
}
}
$custom_content .= $content;
return $custom_content;
}
add_filter( 'the_content', 'wpb_last_updated_date' );
Related Posts:
- Get date numerical and separate?
- Get date function not working
- Display Year and Month from custom field + Age Calculator
- How to make a image-size selected by default in Media upload – WP v3.5
- Apply class to every paragraph that holds image?
- Remove “Insert from URL” link in Media upload – WP 3.5
- static variable loop not working in WordPress
- adding a filter to a shortcode?
- Set media upload attachment link to none and hide it in WP v3.5
- Change the footer text on the login page
- add_filter to post-gallery and remove all ‘s?
- How to overwrite youtube embed?
- Rewriting search and pagination base
- Check if page parent has certain template
- Change comments form title on a page by page basis
- Remove class that has been added by parent theme
- WordPress returns a wrong date
- How do I know what variables are passed in a filter/action and what their meaning is?
- Why do filters/actions require an argument count?
- Unable to set right time in admin and frontend template
- wrong php date()?
- How to use return in my custom function instead of echo
- Run a filter when a walker runs
- display month in french in wordpress/php?
- Handling Body class based on Template
- Get_avatar filter?
- Displaying the Month and Year that a page was Created?
- Add a class to the anchor tag on HTML5 gallery
- add_action shortcut?
- How can I remove a function that has been added to wordpress with add_filter?
- How to control WordPress image metadata (using Imagick)?
- How do I add custom bulk actions to multiple custom post types?
- Add data attribute to each li in menu
- Removing “wpautop” (auto tags) only on certain pages?
- WordPress Gravatar filter is removing my custom attributes
- Generating an nonce for Content Security Policy and all scripts – How to make it match/persist for each page load?
- Unique icons next to each WordPress menu item
- Alter required message using comment form api
- Add item to top of menu using a filter in functions.php
- How to make modifications only to certain elements of an HTML string on the server-side?
- Override a function defined in wp-includes/comment-template.php
- Find hours between post_date and post_date_gmt
- Filtering a function’ output for a new continued function
- Deleting Certain terms from appearing on the front end as links
- Content filter won’t work
- Warning: in_array() null given in PHP function
- How to get User Time Zone in WordPress?
- Upload multiple files in randomly generated folder using wp_upload_bits
- Create page template via functions.php?
- Add meta tags to a custom header
- How do I check or test a WordPress Auto Year Change Script?
- How to have different site identity logos on each page on Astra Theme [closed]
- Custom query vars filters problem with pagination
- Get the name of menu item with wp_nav_menu
- How to add aria role and schema markup to custom walker container
- Must filter functions receive all arguments passed to them?
- User filter posts by year
- If Post Published Date or Modified Date is 1 Year or Older, Display Notice on Post Page
- How to remove get_header From all single pages in wordpress with functions.php without plugin?
- Apply function.php filter only if url not has /amp/
- Change lost password url to a mailto URL in WordPress
- WordPress wrong dates bug
- Remove span tags from WooCommerce Downloads page
- How to bind each “the_content” elements to a custom variables
- Reload page with a different shortcode when a user selects from a dropdown
- WordPress Ajax filter: Create two loops for different output styles?
- Can’t add to time? [closed]
- Custom Bulk Actions handler not firing
- How to generate customized filtered output for the gallery
- How to remove title tag with this filter
- str_replace not preserving whitespace
- Adding a number to a date
- Woocommerce Price Text
- Limit Taxonomy Parents
- Display a post based on its metabox selection
- Search box background on a different page template
- Display a list of users with avatar filterable with alphabets
- AJAX: WordPress filters inside $html do not work as intended
- Assign new post author IF another user in custom field on post transition
- Add attribute to featured image with filter (wp_get_attachment_image_attributes)
- How to add different menu items on different menus?
- Convert custom field date format to “WordPress default”
- How to pass value to add_filter wpcf7_form_tag from another function?
- Add text below WooCommerce short description if metabox value is true
- Is there a hook that I can use when a fatal error occurs?
- Execute a shortcode when clicking on a image
- How do I display a user’s previous orders as a select box option on a product?
- How to combine wordpress_logged_in cookies in one cookie?
- Run a code only on theme activation only during first activation
- Shortcode from a function not working
- Creating WordPress Shortcode with Variable
- Ajax filter button display all posts
- Check If Post Was Published More Than 6 Months Ago Using get_the_date
- How to prevent a function from running based on host (ie web vs local)?
- Multiple Tag Filtering
- Notice: Undefined variable
- Need help with PHP functions
- WordPress styling recent post
- How do I change the Go To Categories link in the term_updated_messages
- How to limit the number of posts in the wordpress loop in conjunction with the “download more” button?