This can be done but we need to see the if statement that is around your div. Right now you that code above will still present the div, just not the content IN the div. You need to wrap that link code in the same if statement that your div is in.
example: if your div if statement is:
if ( has_term( 'Accessories', 'product_cat', $post->ID ) ) {
echo '<div class="upsells products" id="tab-accessories">CONTENT OF DIV</div>';
}
wrap your link earlier in the code with the same if statement:
if ( has_term( 'Accessories', 'product_cat', $post->ID ) ) {
echo '<li><a href="#tab-accessories">Accessories</a></li>';
}
whatever happens to one will be the same as the other.
Related Posts:
- How to set and use global variables? Or why not to use them at all
- How to Add Image to WordPress RSS-Feed with no Plug-in?
- Is it possible to disable a function of a parent theme?
- Hide old attachments from wp media library
- Enqueue Javascript Correctly for 3.5
- How to add active class to custom menu using while loop and wp_list_pages
- Cleanest/Fastest way to avoid calling and retrieving data from the database multiple times?
- Add footer.php to WordPress child theme
- Need to get specific data from array
- WooCommerce – Display variation custom field value [closed]
- Restrict WordPress File Type Uploads by User Type
- Problems with function on function.php
- Woocommerce HTML email option unavailable
- Use template for posts with a particular category grandparent
- How to slow down server response
- Click loads template via ajax
- How to change a public function inside a class of a plugin?
- Randomise upload filenames (or another solution to hide the original image URL from theft?)
- Function set default image when image not present
- Use menu link or onClick to set a variable
- Automatically remove a canceled order in Woocommerce
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- How to remove or change the “W” icon in “My Sites”?
- How to add seperate classes to no-search-result and found-search-result pages on wordrpess search – is_search()
- How to prevent WP_Query function from returning all posts when empty?
- wp_trim_words() does not work with my code Am I doing any mistake in my code?
- Woocommerce: hook action/filter I could use to add variation id and price with each attribute opt on WooCommerce Rest api
- Firing schema via code in functions.php doesn’t work
- A non-numeric value encountered in /wp-includes/functions.php on line 68
- dynamic dependent select dropdown
- Generating an nonce for Content Security Policy and all scripts – How to make it match/persist for each page load?
- getting logged in user info (wp-load.php) from parent directory
- Blog posts repeat
- Ajax load more button for comments wordpress
- Update user profile information from functions.php
- wp-comments-post.php file returns a blank page
- Add .htm extention to a custom taxonomy
- Custom gallery in wp3.5
- How can I modify footer when footer.php calls to another file?
- How to fix this warning:call_user_func_array() expects exactly 2 parameters, 1 given in D:\wamp\www\…….\wp-includes\class-wp-hook.php on line 286
- How to set the WordPress logo programmatically with PHP
- How to use theme function in post/page?
- esc_url( ) won’t use https
- Function won’t run onclick using Ajax
- Where is this function’s callback getting its arguments from?
- Why does the post_type_link hook everything twice?
- Warning: in_array() null given in PHP function
- Use post ID in functions.php file adminside
- How to: Conditionally Enqueue JS and Stylesheets, for Custom Post Type (Single and Archive Templates)
- List all blogs, but exclude the main site
- use loop to return blog details
- How can I count ACF sub_field with a certain value
- change the default order of posts only for specific categories
- Adding function to child theme’s function.php
- Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
- Custom posts password protect
- How to get post category list as select in front-end?
- How to use functions [closed]
- Splitting the_content() by size?
- Function to call either single post or category
- WP Container Displaying Only on First Page of Archive
- Updating Metadata with Shortcode
- can’t load .po file in functions.php
- WP-Bakery – Add custom colors to buttons with template colors
- Woocommerce – Exclude variation attribute on specific variation
- How do I add a function to parent theme
- Are there any drawbacks on opening a session_start in functions.php and header.php?
- Create shortcode for metabox gallery
- Add Pre-Defined Value to Click Counter in WordPress
- How can I redefine WordPress wp-content directory programmatically?
- Trim Titles Only On Some Pages
- How to move a post from one category to another
- Show data obtained from a function and place it in a shortocode function
- How to override theme’s public static function inside of a trait?
- Delete empty title_tags, find a h1 heading and echo it
- Enqueue sripts and styles only if function is called
- WP_Query To Display Product Of Brand On Taxonomy Page
- ajaxurl usage for a custom function
- oembed facebook link?
- Open/closed function [closed]
- How can I export data without using any import/export plugin
- Search for images that width and height is more than 500
- add a value to an external link query in searchform
- wordpress ajax return 0
- My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
- site_url() returns with additional backslashes
- Overwriting a Shortcode
- How to get category pages to look like a certain archive page?
- WP Ecommerce: Display the “Order Notes” as column in the Sales Log [closed]
- How to call a specific value within the functions.php file?
- A next page function with shortcode?
- What is the wrong with this function to enqueue the scripts and styles to the theme? [closed]
- Warning: Attempt to read property “term_id” on int – Woocommerce
- Warning: filemtime(): stat failed for wp_
- Keep users logged in Without Remember Me
- How to use js variable to php in wordpress functions.php
- Why a class property becomes empty?
- Hide category by tag
- add_rewrite_rule image from /images/site2/favicon.ico to /favico.ico
- Background Tasks in a WP Cronjob?