The answer is “it depends” as usual 🙂
You can do it with hooks and I would recommand action-hook in this case or you can do it on your own.
In both cases : define your function in a plugin, functions.php
could be fine but be sure your function is not critical and can be dropped when you change theme.
If you do not want to use action-hooks be sure to test if function exists before using it in a template :
if( function_exists('Ciusan_NBar') ){
Ciusan_NBar();
}
Regarding the function declaration I would recommand you some coding standards, for example :
if( 'yes' === $options['CNB_Showing'] )
It’s better to put variable to the right in case you omit an equal sign.
Related Posts:
- What’s the difference between esc_html, esc_attr, esc_html_e, and so on?
- Is it possible to rename a post format?
- Is there a hook or function I can use to display all theme files being used on a current page?
- How to paginate the get_users function?
- How can I remove the title “leave a reply” in the comment box in twentyeleven?
- Child theme – overriding add_image_size by a child theme [duplicate]
- Check if has any sidebar active on current page
- Compare post levels and user levels wishlist member
- Change ul class=”children” for wp_list_pages?
- Target a certain page within wordpress backend (admin) i.e. Pages > About
- Set default options for inserting media
- Login using the password from protected pages
- Remove tag on my RSS Feed
- Automated mark posts as featured every day
- Enqueuing External Javascript functions.php
- Child Theme Not Overriding Parent Theme
- Function to wrap the_content in a div
- How to run a function once on every post in database?
- Date/time limitation of posts where function must be executed
- Custom image size in Media Dropdown
- Trouble using antispambot()
- Polylang: pll_e() & pll__() on functions.php, doesn’t work
- Post Pagination Showing Same Posts Every Page
- WP_Remote_Get Not working
- Debugging with functions.php
- How to filter a table in post content without plugins? [closed]
- Getting first Image from post
- Inserting a functions output after the content
- Combine two different filter callback functions
- Having issues with a foreach inside of a shortcode with ACF gallery
- Don’t delete a page if it holds users
- Is there an alternative to get_template_directory_uri()?
- Word Press – Dynamic Content [closed]
- Change label for registration Fields
- Warning: : DOMDocument::loadHTML(): Empty string supplied as input in functions.php when adding classes to post images
- Remove stylesheets from Campaign Monitor plugin
- How to install Segment on WordPress without a plugin
- How to search using ajax for exact phrase or words in an input field?
- Categories as main menu items and subcategories as nested lists
- woocommerce change currency per category [closed]
- I can’t enqueue my scripts – They literally aren’t being added to my site
- Using wp_redirect and .htaccess to re-route searches (and pass along the remaining GET vars)
- Multisite 404 on pages – rewrite error breaks database
- Dashboard widget custom positioning?
- Make wp_link_pages() suitable for Twitter Bootstrap markup
- How to get data from an array using get_user_meta()
- I can’t seem to install Font Awesome locally [closed]
- Prevent custom field from being updated after first publish
- laoding bloginfo url in function array?
- How to edit classes in body tag?
- Add a field into a shortcode of an extension
- $_Get and &_REQUEST Index Undefined on Functions.php
- Need a method to prevent WP from adding in between my shortcodes
- How to edit/replace Parent functions.php function in Child Theme to add “Walker” class
- Load scripts for do_shortcode( ‘ [ my_shortcode ] ‘ )
- get_terms and meta_value results blank
- How to modify get_the_excerpt() when post-format equals ‘quote’?
- How to print the current post depth as update notification?
- How to safely edit functions.php
- Linking Javascript in functions.php file
- Enqueueing scripts selectively & activation where needed
- Overwriting TwentyTwelve template file with child theme template, but lower in the hierarchy
- Using One Function To Create Two Different Shortcodes
- Change Page Title
- How to Not Show posts on Category page?
- Put images in the media from url functions
- Paragraph spaces in email template function
- Is it possible to load recaptcha script only in url with fragment identifier (#)?
- page shows short code not output
- Including Font Awesome in a Custom Theme
- Scheduled post delete – can’t pass the cron arguments
- Prevent function from triggering on current page
- Assign IDs to headings in ACF using functions.php
- How would I correctly implement a new if statement in a child functions file?
- Multiple Notifications SetInterval
- Child Theme not loading multiple stylesheets
- How To Show Shortcodes In WordPress Custom Fields?
- Language Switch Function
- How to debug function file causing white screen
- Post date on Custom field
- Fatal error: Call to undefined function add_action() – an untouched problem
- Author info does not show up when author has no posts
- How to wp_enqueue_script with html?
- Load CSS conditional on custom field is present
- Modify sub_menu function to show pages below a specifically set page
- Add custom class to all URLs on entire site
- Is it possible to change parameters of Parent theme function in the Child theme?
- Unregistering custom tinymce plugin?
- Combining wp_current_user() and a variable
- Init hook for header send
- java script error Uncaught SyntaxError: Unexpected token ILLEGAL
- site_url is not honoring scheme
- Problem with woocommerce recalculating tax on completed orders
- How to create a post without link in wordpress?
- Insert image between X number of posts but on specific paginated pages?
- wp_head not injecting css
- Call wordpress function through functions.php when pressing menu
- dynamically import array from another js file in WordPress
- Disable Attachment Page Except for Category
- Is it possible to set the first image from a gallery as the product image, rather than the featured image?