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?
- Gutenberg editor add a custom category as wrapper for custom blocks
- How to display non-hierarchical taxonomy as terms with checkboxes?
- How to remove categories filter from wordpress admin?
- Decreasing the Memory Consumption of a WordPress Site?
- 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
- Changing Top Level Items into Radio Buttons in the Categories Meta Box?
- 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?
- Moving Categories submenu to Media, but still opens Posts menu
- One WordPress Install, Two Categories. Each Category Gets a Domain
- 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
- Select category in custom query
- 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
- 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]
- What is the advantage of using header-catname.php over is_category(‘catname’);?
- Remove ‘rel’ attributes from the_category() output
- 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
- 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?
- 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 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
- 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?
- 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 nest specific category thumbnails inside different containers
- How can i change what one category displays?
- Two Sections on Woocommerce Catergory Page [closed]
- How to let the user create a selection of categories via the backend
- Custom meta boxes ID prefix showing on first category but not others
- Add code to header based on category for specific posts?
- Custom css per category and per single post belong in each category
- Using in ‘category_name’ in ‘$query->set();’?
- How to hide widget from certain category
- How to add icon over specific thumb
- Problem with Custom Post Type Categories
- List post only under the category, exclude child category content
- SQL query to get posts from multiple categories but not in a category
- wp_delete_term or wp_delete_category?
- Custom Portfolio Page
- WP Category Meta plugin fix? [closed]
- I need advice on how to structure the categories according to the layout i have
- How to add meta description, keywords, custom title to a category template
- Make separate text boxes for separate WordPress Custom Fields
- separate posts to have (kind of) 2 blogs?
- create relationship between posts from one category and posts from another category
- Add a custom field when adding / editing a page / post in admin panel
- When creating a new product, auto assign it to all custom taxonomy woocommerce
- How can I make a category function as a page?
- Default URL for category dropdown select option
- Need help to structure our a complex hierarchy
- Using a template page parent breaks page
- How can I add metaboxs to Admin Bar?
- Inserting categories as a hierarchical terms from frontend form
- How to add a post with new Taxonomy without assigning to default category?
- Getting page/category content to show up in my custom page template
- How do you add Author and date Published on Category Pages?
- Own Custom Tags/Category page ( posts)
- Gettind 404 not found wen click the view button for a given category custom post type portfolio
- How to create default categories in new installs?
- display certain category on custom template page
- How to add all categories into an array and extract the categories names and use it with a custom meta box
- List all authors by matching custom meta data on a category page
- Anyway to hide a Category in the Categories section when adding/editing a post in WP Admin?
- Show parent-child relationship for categories in the wordpress admin
- Custom permalinks structure
- Remove category number fill
- Limit authors on specific catogories