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:
- Why have on every line
- WordPress and event-driven programming – what is it about?
- What would be a PHP command to erase all posts from category X from the last month?
- Admin Bar (Toolbar) not showing on custom PHP file that loads WordPress
- Display a selected custom product option in WooCommerce cart
- Custom post type column which compares dates?
- Set the transport of the Customizer ‘header_image’ core setting to ‘postMessage’
- Walker class: Problems with understanding how walk() method can be called without error
- Change comments form title on a page by page basis
- Limit the Excerpt field in WP-Admin in words
- How to create different menu’s for not logged in visitors and for logged in members?
- Setting up the child theme so as to enable right-to-left WordPress?
- Custom Loop Pagination on WordPress
- delete an array element when its date expires
- Customized title tag for each page in pagination?
- How to break down importing of feeds
- Wrap First Character after in a tag
- How do I implement a .diff changeset from core.trac.wordpress.org locally?
- Multiple choice in a custom taxonomy
- Random Default Avatar Function
- Customizer: Output default value in Customizer CSS
- How to add just one specific page to widget without plugin?
- Taxonomy linked to pages
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- WP dynamic featured image – Can’t get second featured image url
- Converting HTML Template to WordPress Theme
- Can I install/embed WordPress on a ‘single page’?
- How to check if a meta value has already been assigned to any user?
- How to hide products that do not have an image from a slider carousel for an ecommerce webpage?
- Send an email to specific adress when button is clicked?
- WordPress admin pointers tour bug?
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- Custom posts in different columns style
- need help with existing code showing subpages
- How do I add a custom css to all posts without affecting homepage css? [closed]
- how to show only specific category for a template
- Advanced Custom Fields not displaying
- How to get private property in parent class into extended class?
- Exclude posts with specific metadata from search?
- Add data-id attribute to child page links
- What file have I to create in my custom WordPress theme to show all the post belonging to a specific category?
- Warning: Illegal string offset on theme options page [closed]
- Clickable image link sends people to wrong URL
- Display Youtube Time Automate from Key
- How to fix this PHP warning in WP-Admin after upgrading to 3.1.2?
- Where is the PHP code generating an element?
- Basic wpdb update question
- Check class_exists before class definition / Doxygen problem
- Extract links from content
- Integrating Yii2 and WordPress
- WordPress widget and customize.php not working in Ubuntu16.04 VPS
- Custom Registration username_exists / email_exists
- After disabling WPML multi currency, the currency is still handled by the WPML
- How do i wrap woocomerce attribute in list?
- PHP Helper Class to create shortcodes
- Is it possible to add a custom page to a free WordPress site? [closed]
- Is there a hack for using is_page() within the function.php file?
- save metabox with new values _wp_page_template
- How to Fix an Archive.php That Displays All Posts?
- Assign Custom classes to every Excerpt
- Make next post button link to random post
- pagination broken – clicking next displays “page not found”
- Site DOES NOT LOAD after 3.1 update
- Create condition for Author bio Social Links
- WP-Bakery – Add custom colors to buttons with template colors
- Woocommerce template file outputting tags
- Trying to update Woocommerce meta values
- update_user_meta as multiple value but with same meta key
- retrieve “Link Color” value
- If Statement is Ignored?
- Delete post meta by serialized meta value
- Dynamic Banner Text based on Subdomain
- Create “blank” admin page without having admin-bar/admin-menu for faster load
- Create Schema in WordPress with PHP
- Create form which redirects to site in network?
- Search only for posts with specific metadata?
- What image is this pulling?
- How to associate dynamic PHP page for chosen WordPress tag?
- Only display notification on single post
- Is there a way to have chunks of a page’s content expire?
- Where can I find the declaration of `$_wp_theme_features`?
- Static home page ignored
- How do I routinely extract the thumbnail of the most recent post?
- Showing the project type in HREF
- Display tab title as ‘blog tagline | blog title’
- My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
- Showing custom field contents without listing description
- Check if values exists DB
- Auto create description in post
- Pagination on Custom Loop
- error with WP custom form
- WordPress causing all code to be displayed on line 1. Receiving multiple errors after cleaning cookies and cache
- How can I clear the theme mod settings?
- MySQL Engine vs. Charset
- Custom PHP-coding in MU installs
- Date when the custom field was added
- Select area and checkbox data is not saving?
- HTML in PHP problem [closed]
- In reading settings posts are set to “blog” and I have page-blog.php but no posts
- WP Custom tables query