Add another layer of condition to your is_archive()
test, so that your archive class is only output when the other two are NOT true:
function fotogruf_layout_class(){
if ( is_search() ) {
echo $search_layout_class;
}
if ( (is_post_type_archive('gallery') ) || ( taxonomy_exists('gallery_category') ) ){
echo $gallery_layout_class;
}
if ( is_archive() ) {
if ( ( !is_post_type_archive('gallery') ) || ( !taxonomy_exists('gallery_category') ) ) {
echo $archive_layout_class;
}
}
}
WP’s built in body classes might do this for you automatically if implemented. Maybe not to the level of detail you are looking for, however. https://developer.wordpress.org/reference/functions/body_class/
Related Posts:
- Suppress the_content filter in a nested loop
- Is there any filter or action hook to remove layout classes from appearing in my templates?
- get_template_part vs action hooks in themes
- after_setup_theme always runs
- When to use add_action(‘init’) vs add_action(‘wp_enqueue_scripts’)
- How to remove the Theme Customization Button from the dashboard and themes options page?
- What filters are applied to the_content function?
- Change admin bar to default:off
- How to modify an image block in Gutenberg WordPress 5?
- Edit srcset and sizes attributes in Gutenberg image, cover and gallery – blocks
- Getting instance variable in scope of ‘wp_enqueue_scripts’
- wp_get_attachment_image_attributes not working for me
- Display a different theme for not logged-in users
- How do I Make a Theme “plugin-ready”?
- What is a good way to pass a variable from add_action to a Theme?
- Run shortcode before filters
- How to access certain WP functions inside custom class, in theme folder
- Add class to before_widget for all widgets with a dropdown and a counter
- How to Auto Approve Comments on a Specific Page?
- Theme elements not translating
- What’s the difference between hooks, filters and actions? [duplicate]
- How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’
- Get password when user registers and save it sha1 into database
- Passing variable in hooks and filter
- WordPress nav_menu_css_class theme filter is not being called
- customizing the_password_form filter
- What’s the best action to use when you want to do something only once per theme setup?
- WordPress Genesis Child Theme Filter divs
- Change file name from wp_generate_attachment_metadata
- How to write .htaccess dynamically? [closed]
- Use debugging for add action events
- after_setup_theme, Global Variable and Theme Customizer
- Is there an action for save_menu and/or update_menu?
- How to make content editable from admin page?
- Simple way to get two language WP site
- Highlight “Show all” item in wp_list_categories
- When trying to override plugin’s function by theme, my filter executes two times, I want it to run only a single time
- Menu item added in wp_nav_menu_items filter is never highlighted
- Should I use add_filter for functions in function.php of the theme?
- Pass variable to hook. Its possible?
- Does the switch_theme action run when you’re upgrading a theme?
- Filter categories used with Custom Structure Permalink
- Replace function in a child theme
- How to wrap all titles generated by Gutenberg “Heading” block with tag
- Replace single_template filter with what for default posts?
- save_post action doesn’t passing post id to my function as argument
- Unique design inside a specific category’s url
- How to rotate every letter in a title
- Overide enqueue in non plugable function via child theme
- How to disable thumbnail filter for a specific template part or image size?
- CSS class on last post in loop ( custom query )
- How to change footer credit text in Twenty Twenty One theme with a hook?
- Use a filter on menu items that have children
- Modify available templates (in dropdown)
- tiny_mce_before_init: ‘exact’ => true has no effect
- Never actually adding the action? Or do I have to call the action?
- How to conditionally add a wp_filter
- Add content after get_header
- Filter didn’t work on content class (hybrid_post_attributes)
- How to set default values for edit_post_link() in my theme?
- Tiny MCE custom styles, and preview in the backend
- content filter (add_filter) for category description?
- How to make a function occurs for one time?
- Related Post Category Filter
- Pagination don’t work with active filters
- How to register dynamic settings in WordPress Customizer?
- restrain filter on get_the_excerpt to queried item in stead of current post
- WordPress wp_get_current_user returning blank values until refresh
- Alternative solution for script_loader_tag?
- Remove action added in plugin class from theme
- Alt header logo and link for specific pages
- WordPress Twenty-Fourteen: How to Remove Home Page Header Image from Other Pages
- Make a custom field in admin post.php read only
- Hook in parent theme Menu function
- How do I remove p tag *insertions*? Disabling `wpautop` removes manual tags
- How to add custom nav_menu_css_class to certain menu only?
- How to manipulate wordpress template tags’ output
- what is do_action(); in wordpress? [duplicate]
- add_action not working in header?
- apply_filters to featured image
- Add rel to all images in a post
- Is there a way to prevent wp_head from outputting self-closing tags?
- Theme’s featured image option is not showing up
- Add text when displying attribute with a hook on single product page
- Only show read more text when when wp:post-excerpt meets excerptLength
- WP “optimizing” PNGs into thumbnails 5X larger than originals – FIX
- optimized PNGs 5X larger than originals
- Menu items description? Custom Walker for wp_nav_menu()
- How to define and link full path to css located at a random folder on header.php
- Sizing screenshot.png without losing aspect ratio
- Software for WordPress Theme and Plugin Development? [closed]
- When to use is_home() vs is_front_page()?
- What is the preferred way to add custom javascript files to the site?
- remove_action or remove_filter with external classes?
- Passing a parameter to filter and action functions
- Difference Between Filter and Action Hooks?
- Get the blog page URL set in Options
- How to create .pot files with POedit?
- How do I get the theme URL in PHP?
- How to know what functions are hooked to an action/filter?