Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Remove post from latest posts after a month only with certain tag

This can be solved with hundreds of plugins, but I’m happy that someone wants to make it with code.

So that you want is actually not to hidden something but to just take the posts after the one month ago date.

$onemonth_before = date( 'Y-m-d',strtotime('-1 month') );
$args = array(
    //if you have custom post type 
    'post_type' => 'your-post-type',
    'posts_per_page' => 20,
    'post_status' => 'publish',
    'tag' => 'sometag',
    'date_query' => array(
        'after' => $onemonth_before,
        'inclusive' => true,
    ),
);
$query = new WP_Query( $args );

This maybe needs some changes to work in you case.

Some more info about the powerful date_query can be found in the
codex

Related Posts:

  1. Exclude from the query posts with meta_key and meta_value
  2. Add options to featured image
  3. mysql custom wp query
  4. Change meta tags programatically
  5. Use a function to update post meta based on other post meta
  6. update_post_meta for custom field not working upon form submission
  7. WordPress – thumbnail image from youtube (function and loop)
  8. Assign category using custom field?
  9. Convert User ID’s to User Names in a single.php file
  10. Can’t check if a post has thumbnail adding filter to get_post_metadata()
  11. Move Post to different category if post_meta field is 0 or is 2 days old?
  12. What WordPress function to use to get meta value by using meta keys?
  13. show first 3 thumbnails of posts in different sizes [closed]
  14. Default Custom Field Value Automatically Update
  15. Post meta not updating
  16. Function to update post_meta based on existing post_meta
  17. How to obtain the recent posts without their content in an efficient way?
  18. Prevent custom field from being updated after first publish
  19. Get array of metakey in all posts
  20. User function to return multiple get_post_meta()
  21. What are the meta fields for an attachment?
  22. Using functions.php to include code that’s processed inline
  23. Getting images from media library and get_the_date() not working
  24. How to avoid saving empty data to sql while using add_meta_box
  25. How to change text color depending on the number value (Using javascript)
  26. How to add custom metakey to shop_order page’s searching function?
  27. Update wp_postmeta table based on 2 keys
  28. blank page with wp_get_attachment
  29. Reference multiple style sheets, clearing styles for permalink page, custom fields for css
  30. How To Display Author Popup on Entry Meta (Genesis Framework)?
  31. Creating a “Related Meta” type field?
  32. save_post doesn’t correctly process function call with php class
  33. Pagination not working on my archive page for a custom post type
  34. Return ACF Field value function
  35. update_post_meta not working in function
  36. How To Get WordPress Categories Last Update Date?
  37. How to add a meta information to the URL?
  38. Automatically add custom fields (post_meta) to all published posts, hourly, via wp_cron?
  39. update_post_meta after form is submited
  40. Add custom fields after post/page title
  41. Display post_meta-by_key on product catalogue
  42. Integrating custom API for post content into Admin interface & Public Website [closed]
  43. How to save custom made object in an array in a post meta field
  44. Adding and updating repeating custom field meta data
  45. How can i listing current category and Featured Category post list?
  46. How to place a div inside a function that creates a div
  47. Echo post title in post
  48. Unable to Change “Pages:” Before WP_LINK_PAGES
  49. colorbox not loading in
  50. dynamic enquiry form [closed]
  51. wp_get_archives() output
  52. I would like single.php to act just like index.php
  53. Conditional function for excluding first image from content, not working
  54. Does WordPress has an automatic link parse function?
  55. Fatal error: allowed memory size when after using enqueue_script
  56. The work of WordPress Function update_post
  57. Custom attributes to javascript tags
  58. How to add php within jquery
  59. Is it possible to put a function somewhere other than the functions.php file?
  60. Check if a different page has any attached images
  61. How i can get the URL?
  62. Custom Menu in Admin doesn’t change menu in browser
  63. Show errormessages on wrong username/password on custom loginform?
  64. Function to check if custom page is used by page?
  65. How can I show different content for different user-levels?
  66. WordPress function bloginfo not echoing output on parts of the pages
  67. Using add_image_size in functions.php to get original uploaded file
  68. get_image_tag() html output : empty src attribute
  69. template_redirect action only firing if logged in
  70. show all the posts thumbnails
  71. Changing date query from month
  72. Problems with functions.php! Error! [closed]
  73. Output comment_author in array
  74. Help with IF has focus then… statment
  75. Changing the text of Upload/Insert on Posts and Pages Screen
  76. How to change a specific admin label
  77. How d0 i get the number of attachments in the post
  78. struggling with syntax for the_post_thumbnail();
  79. include w_thumbnail_src in function?
  80. implementing a centralized content “show-do-not-show” toggle?
  81. Multiple, Dynamic, Sidebars Problem – First Sidebar not working properly
  82. A better way to get stats
  83. Looking for Functions File that doesn’t Exist
  84. hook for dashboard show_user_profile
  85. How to add a shortcode to call a function
  86. How can I call a PHP function inside a hardcoded shortcode?
  87. How would I make a function to dynamically determine if user is logged to change navigation menu text?
  88. Get author total post votes from post meta
  89. WordPress comment_form() does not display actual comments
  90. Any adverse effects of adding apply_filters to a function?
  91. WordPress Categories: Function using custom SQL to return array of specific category IDs
  92. How can I remove page titles without removing the link in the navigation bar in twentyeleven?
  93. Problem with WordPress output text (‘esc_html’ & ‘wp_richedit_pre’)
  94. How to apply the ‘current_page_item’ class to an archive page in `wp_list_pages()`?
  95. Conditional custom menu?
  96. What function actually renders the wp_admin_bar ? How can I call it?
  97. Facebook OpenGraph error, Call to undefined function wp_get_attachment_src()
  98. wp_enqueue_script() not working
  99. Simplest Way to Build Custom Archives Page?
  100. Filter for replacing the WP_query object for a given category
Categories functions Tags functions, post-meta, query-posts
Reversing domain ‘sharding’ with htaccess
Theme customizer API get functions

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress