You have chosen to tackle a hard problem for one so new to PHP. 🙂 This might get you closer to your goal:
global $wpdb;
if ( in_array( $pagenow, array('post.php', 'post-new.php') ) ) {
foreach (get_categories() as $category) {
$cat_time = strtotime($category->cat_name);
if ( $cat_time < strtotime('-3 days') || $cat_time > strtotime('+2 months') )
$exclude .= $wpdb->prepare( '%s,', $category->slug );
}
$exclude = substr( $exclude, 0, -1 );
$exclusions = " ($exclusions) AND t.slug NOT IN ($exclude)" ;
}
Related Posts:
- Save metabox checkboxes values to custom content type
- Remove “Parent” Selection When Adding/Editing Categories?
- Render Selected Categories in Admin Edit Post Screen differently
- why is the delete option missing from just one category?
- Only one category per post
- Is there an easy way to make a meta box have the tabs like the Categories meta box has?
- Gutenberg editor add a custom category as wrapper for custom blocks
- How to display non-hierarchical taxonomy as terms with checkboxes?
- How can I hide a category from Contributors in the edit/add new post screen?
- WordPress Multiple Category Search
- How do the ‘tag’ and ‘category’ (default) taxonomies do ‘save_post’ action?
- How to remove categories filter from wordpress admin?
- Checklist of selected categories
- Decreasing the Memory Consumption of a WordPress Site?
- Why aren’t sub-categories nested after creating post in the WP Admin?
- Multiple Domain Names – One WP Install (non-Multisite) – Default Each Domain name to Category Archive
- Use tag interface for hierarchical taxonomy?
- How can I select a primary category?
- how to use a different domain/subdomain for authors/catagories on single site?
- Deleting default category in wordpress
- Delete a specific category when deleting a user
- Changing Top Level Items into Radio Buttons in the Categories Meta Box?
- Admin Panel – Disable Moving Selected Terms To Top of Metabox
- How to list child categories in custom category template?
- Trash bin for categories
- How to Make a Categories Meta Box with Hierarchical Checkboxes on Frontend?
- Add search to list of categories in post editor
- Need help adding custom field to category
- How to set up sub-categories for author pages?
- View category in the preview of Theme Customizer
- Moving Categories submenu to Media, but still opens Posts menu
- One WordPress Install, Two Categories. Each Category Gets a Domain
- Block multiple categories from Blog
- Why adding Categories does not auto refresh in Backend while using my custom theme?
- How to have a static category/author page?
- Create single.php for specific category by category id
- Show posts of one category only with Custom Taxonomy on single.php
- Select category in custom query
- Category Search functionality on category metabox (wordpress admin)
- Restrict categories to a custom post type
- How to stop wordpress from showing the selected category on top of others in the category selection?
- WP 3.0.5: Best way to add custom metaboxes for post categories?
- Order Taxonomy Term by date created
- Apply custom category template to subcategories
- Hide post meta data on a specific category
- Custom Theme Want To Remove One Category From All Displays
- Format Brand value in Category view [closed]
- Add custom taxonomy under the category title
- How to show in search results posts with a particular tag in a particular category?
- What is the advantage of using header-catname.php over is_category(‘catname’);?
- Remove ‘rel’ attributes from the_category() output
- Multiple menu items highlighted
- Want to hide some categories from the categories meta box in the post editor for the two specific user roles
- How to remove the “+Add Category” button from the Category metabox?
- Add Post Screen Keep Category structure
- How can I enable a TINYMCE rich text editor in the admin interface?
- in_category() works in single.php but not in page.php?
- Use a wordpress page to display a certain category
- How to view WordPress’ default category IDs?
- Multiple Category Search
- How do I add a function on a specific post category?
- How to customize category template?
- Category-slug.php not being used
- How would I go about adding custom header images per category?
- Category pie diagram meta box in post editing page
- How to filter out Categories for specific post types on WordPress Admin?
- Limit a meta box to a specific category
- Display posts separated by Category in Author’s page
- WordPress admin categories sort show is wrong
- How to categorize posts under Category 1 and Category 2 which are separate lists of categories, and display them as separate lists in widgets
- How to organize custom categories for filtering and selecting
- Filtering *out* a taxonomy from the admin post list
- Category control subcategories
- How can I edit the ‘Most Used’ tab in the categories meta-box to show another custom taxonomy?
- Use Tag input metabox style for Categories
- How to rewrite the post URL according to the category?
- WP admin broken. Not saving catgories or adding categories to menu
- How to build a simple nav system of custom post type categories and its posts?
- Admin comments and user restrictions
- Display thumbnails for certain category posts
- Keyword search in multiple categories
- Is it possible to remove from default category widget?
- How to customize my category pages
- Admin: Navigation Menus do not show empty categories/taxonomies in the list’s search tab
- How to make the ‘delete’ button inactive on some categories?
- add slug beside name in Admin Category Checklists
- Two columns in homepage each with one category
- How to modify the output of wp_terms_checklist when used within the built-in category metabox on edit posts?
- Custom Meta Box (SELECT2) Not Saving Taxonomy Terms
- Multiple selection for wordpress widget
- Different CSS class by category
- how to nest specific category thumbnails inside different containers
- Wrong category nice name is displayed on archive page
- How can i change what one category displays?
- Remove any product that is featured from regular display loop [WooCommerce]
- Two Sections on Woocommerce Catergory Page [closed]
- How to let the user create a selection of categories via the backend
- Theme for subcategories
- How to restrict the amount of categories/post tags/terms for a post type post
- Custom meta boxes ID prefix showing on first category but not others