The problem is that is_category
does not do what you thought it does. is_category( 'keep' )
tests that the current page is a category archive for the category keep
, it does not check if the current attachment/post is in the keep
category.
The official WordPress developers docs for is_category
start with:
Determines whether the query is for an existing category archive page.
https://developer.wordpress.org/reference/functions/is_category/
Instead, what you want is to check if the current post has a category assigned, aka has_category
:
has_category( string|int|array $category = '', int|WP_Post $post = null ): bool
Checks if the current post has any of given category.
https://developer.wordpress.org/reference/functions/has_category/
Related Posts:
- remove links from images using functions.php
- Masking logout URL
- How to add classes to images based on their categories?
- Logout/login redirect CSS issue
- Paged Single Post doesn’t redirect to the main url after Removing Pagination
- Auto delete WordPress images/thumbnails (all sizes) and featured after X days/hours, or similar?
- redirect wp-login.php to another page
- How do I redirect upon login a specific user based on role?
- How to add a rel attribute to images that contains their categories?
- Best way to programatically add “rel” attributes to page and post images
- What is the “icon” parameter in wp_get_attachment_image_src used for?
- Find first image on paginated post for Pinterest
- Ninja form Redirect depending on text field content [closed]
- How do I permanently Disable Attachment Post URL
- Redirect specific page in WordPress for first time visit
- Can’t check if a post has thumbnail adding filter to get_post_metadata()
- How do I redirect all 404 error url to Subcategory url
- Image rotation fails to regenerate custom sized thumbnail
- Display images that are not in the content
- 404 redirect to previous category
- Login Redirect if Logged in from Specific Page
- Redirect to another page if the user is logged in when pressing again the login button on menu bar
- Incorrect redirect after commenting
- Can’t filter wp_get_attachment_link
- Get ID of first image attached to a post
- How to stop wordpress from injecting hard-coded style into image attachments with captions
- How i can put $_GET codes in function.php?
- Why does get_template_directory_uri() not include “www”, only for enqueued stylesheets?
- How to hide image-url if no attachment?
- attachment page template? only show attachments for current post?
- How to get an attachment id from a filename
- Page get parameter doesn’t work with is_single() function
- What are the meta fields for an attachment?
- Redirect website domain (including all pages) to external URL after Popup message (few seconds)
- Contact Form 7 If Condition
- Solved: redirect to another page using functions.php
- Redirect to other page if login
- Logout Redirect and also WP-login.php Redirect
- How to add array [closed]
- WordPress website keeps loading the maintenance page
- Remove attachment page for audio media type only
- Redirects based on a JSON file
- Get Attachment Category Name
- template_redirect action only firing if logged in
- How d0 i get the number of attachments in the post
- How to redirect Subscribers on login to specific page, when logging in from a Page
- Different image using srcset function
- Auto delete content in specific folder inside media library
- Redirect to one of two pages after data submitted, depending on the current url
- WP_Query for Attachments not working as expected
- How to update an image attachment’s alt text from a custom field when saving a post?
- Wildcard 301 Redirect Using Theme Function
- Competing Login Redirects – Need to be Combined?
- Postback redirect through add_action is not triggered
- Restrict access if logged out except for homepage
- Redirect specific author posts to another url
- Remove all video attachment, both files and post/postmeta from database?
- Custom download page
- How to create a function to redirect a specified page to another page
- Language switcher for subdomains
- Open image size links in a page instead of direct image link
- Allow the access over wp-login.php
- Set thumbnail from URL, by grabbing image in functions.php
- How to request login for user but not for bots
- Making an under maintenance page (without using plugins)
- Template Redirect Function Only Working When Logged In
- Advantages and disadvantages of using automatic-feed-links
- Convert hyphen to underscore in permalinks
- Displaying Widgets
- Display WooCommerce subscriptions for user [closed]
- Removing the main link to Jetpack from the menu
- Post thumbnail not showing in WP admin area for custom post type
- Fatal error: Cannot redeclare when switching themes
- How can I grab the video id of youtube?
- Specify number of posts for sub-category page
- Passing variable as add_shortcode argument
- comments_popup_link without echo?
- add_action wp_enqueue_script priority level only works for admins
- Writing a function to detect an event
- Sort and display pages with specific custom field (not tag)
- WordPress login set cookie that survive browser exit (wp_signon function)
- Show metadata in users.php – wordpress
- Add version # to wp_register_style function
- a SET of wordpress native galleries with title and text?
- Only display table in the_content() in canonical page
- Button click counter for login user
- different body classes for each category
- How to override or change function in form.php in a plugin
- Some code is added automatically to my site’s header – what is it?
- To make some div display for a longer time
- Cant use php fopen() function in functions.php
- Different ads on every website on multisite environment
- WordPress Custom wp mail template return full template
- Comment turned Invisible
- How do i set global variable in a function in wordpress functions.php
- Working function() doesn’t execute when triggered by WP CRON
- WordPress – Notice: Function wp_enqueue_script was called incorrectly
- How to add more than one menu for logged in members?
- post_row_actions filter from parent theme not executing in child theme
- Is it possible to set the first image from a gallery as the product image, rather than the featured image?