See this related question. I guess in your case you’d wrap your code in if( $args->theme_location == 'primary-menu' )
.
Related Posts:
- Adding a second email address to a completed order in WooCommerce [closed]
- Possible to search by author name with default WordPress search function?
- Advantages and disadvantages of using automatic-feed-links
- current_cat_ancestor Alternatives
- Change number of posts to show on Archive page (custom post type)
- How to use wp_get_recent_posts with many post types?
- Add body class of category parent
- Roles & capabilities GUI that does not create separate table
- Why get_header() or get_footer() does not run twice if called in the same php file?
- How to update WordPress and plugins at specific day and time in PHP?
- Max file size not updating
- Create thumbnail on PDF upload with Gravity Forms
- How to override filter in child theme?
- Use Exact Image Size using add_image_size
- How can I tell when a user is logged in?
- Enqueue Style in Functions.php
- How allow users to save list of posts?
- Formatting Multiple add_theme_support Arguments
- Different functions file for each site in multisite installation?
- jQuery plugin function is not a function
- Limit posts only on home page – ideally in functions.php
- Make Categories a Dropdown Menu in Media Library
- How to add css class to image attached in all the posts?
- If is multiple page templates
- Loop (iterate) through Multi-Site sub-sites (blogs)?
- Proper way of using functions in action hook?
- What will happen if I delete the functions.php file?
- how to add an image to the footer?
- How to properly add function called by action-hooked function to functions.php?
- Get Current User info using wp_localize_script, in functions.php
- How to add new embed handler not supported by oembed?
- How do I permanently Disable Attachment Post URL
- Need to add class=”lightbox” for every single post image
- Child Theme files – what is needed?
- How do I add Bootstrap and LESS to my migrated WordPress site?
- Stuck on maintenance mode
- Not sure if enqueuing js scripts properly
- How to display custom option field in woocommerce orders in admin panel?
- Best practices regarding the creation of custom widgets?
- How to remove style attribute in WordPress RSS output?
- Multiple Loops Meta Data
- Update user meta of author when post content is viewed
- How to stop wordpress from injecting hard-coded style into image attachments with captions
- If ACF field is empty show different value [closed]
- What is the text that appears beside the page titles in the list of pages in the WP admin?
- Two functions with different arguments and add_actions, but identical code
- How to fix get_the_category function returning incorrect slug?
- How i can put $_GET codes in function.php?
- Disabling visual editor on a specific post
- Is there a way to direct unregistered user to registration page when click a link?
- Auto log in hook is requiring a page refresh
- Testing for a shortcode using a function. 404 page throwing PHP Notice
- How to get an attachment id from a filename
- how to get the post ID from wp_insert_post
- How to get post revisions in my custom rest API? [closed]
- Possible to merge these two functions?
- How can I set the SRC URL of the custom logo image?
- The Capability to choose post/page template
- The_content and Preg_replace in loaded Iframe [closed]
- dynamic site link for future migration in echo do_shortcode()
- Hide tab Buddypress profile for visitors, not logged in users
- Use existing image sizes for WooCommerce
- Add a mature content warning to first-time visitors
- Show Featured Image in else statement
- Function to check if custom page is used by page?
- Any adverse effects of adding apply_filters to a function?
- How can I remove page titles without removing the link in the navigation bar in twentyeleven?
- Simplest Way to Build Custom Archives Page?
- Filter for replacing the WP_query object for a given category
- Custom user role still showing up after deletion, ideas?
- wordpress built-in Jalali date convertor
- WordPress Function Assistance with Loop
- Bizarre Child Menu Issue on WP Site
- Populate acf-field, depending on block name
- get variables data from functions.php to template wordpress (without global variables)
- Add Change role button for list of user in an event
- I am trying to set post terms to a custom taxonomy
- how to increase connection time
- Shortcode to insert default text and change one word throughout it?
- Classic TinyMCE messing up only Contributor’s HTML
- Reference multiple style sheets, clearing styles for permalink page, custom fields for css
- Add schema to Search result page’s body. Tried using is_search
- Drop down list code for sidebar
- Shortcode Initialization in a Custom Theme
- Hide disclaimer from summary excerpts
- Disable links to images only if link is an image
- WordPress Javascript Widget jQuery Dependency Issue
- Open image size links in a page instead of direct image link
- Allow tags and attributes in post and pages content
- Override parent theme function that is not hooked or in the functions.php file
- Function to get thumbnail img source
- Syntax for a function in order to get post’s title in JSON encoded response [closed]
- Comment Function
- WP Custom Comment Callback Not Responding
- Do something when user creates post (that’s pending)
- Will my WordPress site become vulnerable after adding this functions which allows more HTML tags for subscribers?
- Add product to cart from functions.php
- How I can show short content with short tag
- Is storing in a variable the result of a fonction a most powerful way to code an if structures in WordPress?
- Add functionality to block comment authors in the Comment edit pag