Completely out of any context (since it’s really not specified in the question), the correct method to enqueue jQuery only in the context of bbPress is to add an appropriate conditional inside of a callback, hooked into wp_enqueue_scripts. For example, the following would be defined in functions.php (i.e. not in a template or template-part file):
function wpse129696_enqueue_scripts() {
// Only enqueue jQuery in the context of bbPress
if ( is_bbpress() ) {
wp_enqueue_script( 'jquery' );
}
}
add_action( 'wp_enqueue_scripts', 'wpse129696_enqueue_scripts' );
Related Posts:
- Function to return true if current page has child pages
- Cleaning up WordPress to improve performance?
- Include a external PHP file into a WordPress Custom Template
- List of all theme customizer control types?
- Show the most popular post per week
- Add a class to links in the visual editor (how to get old dialog back)
- Remove option to allow trackbacks/pingbacks from post page options
- Creating custom Woocommerce attribute taxonomies from a plugin
- Remove/unset options field from backend Settings->General?
- Display posts by month
- How to preserve PHP modifications while upgrading WordPress?
- Removing jQuery migrate and working with dependencies
- Load post content into iframe
- is there a simple way to list every templates / php files used to generate a specific page?
- wp_customize_image_control default value
- How To Customize Position of »add to cart« of WooCommerce on Product Page [closed]
- Search and Replace in database: How to replace data in SQL dump file on Windows?
- Authenticating to WordPress, using my own authentication two-factor system
- Is it recommended to pass some data to scripts in `wp_enqueue_scripts`?
- Overriding a theme redux file in child theme
- there’s a way to include a minimal WP for check only the current user, its roles (caps?) and then release/free it?
- Widgets not showing in my custom theme
- How to display custom field on homepage
- How to display something in a div when the user clicks on a text in another div – no page refresh [closed]
- How to get 2 or multiple custom post types in wordpress functions.php
- Creating bulk posts with Youtube videos
- Change the site tagline (or similar) based on current page
- Trouble creating conditional PHP for nav menu items with children for custom Walker
- Setting custom canonical urls
- Only show search results with if current date is between two dates?
- database interactions using OOP
- create a select input with menus created on a custom options page
- WordPress blog post url on category page
- Extending the WP_Widget_Text class
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- Trying to build simple deposit code that hooks into woocommerce
- user_profile_update_errors hook not executing
- Saving and Restoring a Canvas on A Individual User Basis
- Extend plugin Class through functions.php
- How to add a do_action on refreshing of WP customizer?
- Customize position of social icons in upme plugin [closed]
- Weird 404 URL Problem – domain name being placed at end of urls
- Output custom field value to post string
- Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value
- Media Upload , file name changed automatically
- Replace shortcode in substring
- Need help enqueueing webfonts
- Custom Background by Page IDs
- Change order of custom submenu link in WP Admin?
- Underscore – Self hosted fonts
- I’m trying to create an array with a foreach loop, but the array only stores the last item [closed]
- Hook called before text widget save
- Function Reference Documenting Template Tags for use in Custom Theme Templates?
- str_replace with the_content is not working
- How to create a field in customize and show that in header.php?
- How Do I Find & Remove H1 From Site-Title-Wrapper? [closed]
- List of Events with Multiple Dates: Only NEXT Date
- Set cookie for visitor
- Display movies that apear this day next
- is_user_logged_in returning nothing on custom page
- Customize field names in backend profile edit page through function.php [duplicate]
- how to add datas in taxonomy to post with wp_insert_post
- Change permalink structure specific category
- Array data not saving to specified sections. How to make seting independantly?
- I need to display posts in subcategory beside posts in main category
- Integrate otp in my custom singup form
- Hide A Class and Add Custom HTML Code Using WordPress
- How do I know if the user is a customer?
- How to block specific user id in custom login form?
- I want to fusion the product columns in email table order
- Add a new view on the Woocommerce account page
- How do I add a predefined class to a custom html element?
- Adding new divs with custom classes to products on WooCommerce shop page [closed]
- How to separate the taxonomies list from the form so that editing taxonmies is the same as pages and posts?
- Redirect user role to a specific page on login in a multisite network?
- Add custom attribute to product’s HTML to woocommerce cart page
- Autoloading Classes in Plugins
- Remove node from multisites?
- Automatically refresh page if widget is added to page?
- custom field – changing an element or background of id div – different versions not working
- How to get php file based on URL in WordPress
- Show content by using tags
- Replace Underscore (_) on Space ( )
- Why isn’t my custom Javascript showing up in my custom template?
- A Customizer checkbox control that sets the setting to “” or to “blank” and show() or hide() a color control
- Use custom get results query to show posts WordPress
- How can I show only if custom field has content [closed]
- media-uploader insert into post is not inserting
- How to show all of aspecific post type that has taxonomy and a specific term
- How to hide something from custom home page with php code?
- How To Customize Position of »add to cart« of WooCommerce on Product Page [closed]
- How to add button to top of theme customizer?
- Display a list of users with avatar filterable with alphabets
- How can I add more code to this?
- How does one programmatically manage posts from a external php script?
- How to remove the intro animation which appears during the load up of some WordPress themes? [closed]
- New to WordPress & Freelancing [closed]
- How to change product title color in shop page if product has specific product tag (Woocommerce)?
- Restricting page by user role
- Custom WordPress Customizer Control for Typography Presets renders blank section or fallback , despite correct class registration