If you want to load your js only on page/post view you can do it like this:
function myplugin_enqueue_scripts() {
global $wp_query;
if ( $wp_query->is_single ) {
wp_enqueue_script( 'my_js', ... );
}
}
add_action( 'wp_enqueue_scripts', 'myplugin_enqueue_scripts' );
Related Posts:
- Show Similar Post Titles ( Similar to Stack Exchange )
- How do I unlock a post programmatically?
- Delete Post With No Traffic?
- Automatically Creating Posts for Popular Forum Topics or Products [closed]
- WP get_permalink Return Wrong URL
- Is there a plugin to display certain posts on certain pages? [closed]
- plugin for wp_list_categories with posts
- Replace existing pages with new pages, keep menu links
- Use plugin or custom post type for game score functionality
- View Private Published Page with URL Code (no login required)
- Add category selection to custom post type (plugin)
- Redirect to another page using contact form 7? [closed]
- Moving FB comments at the end of page
- How can i summerize posts or news automatically in word press site?
- Delete data from custom table when deleting a post
- Link Posts to External URL
- Style WordPress Custom Post Type Single Page
- Posts are deleted everyday at night
- Issues with Post 2 Post Plugin
- Get page type to display content
- Does anyone have the Custom Post Permalinks plugin from John P. Bloch? [closed]
- Looking for membership style plugin with edit option [closed]
- is_plugin_active function doesn’t exist
- Proper Way to Modify Plugin
- Looking for a Table of Contents (TOC) plugin for WordPress
- WordPress Plugin Development In MVC Architecture, How?
- Where should I use get_option in a plugin
- GPL and plugins
- Disable Specific Widgets on Selected Pages of a WordPress Website?
- Create page when plugin is activated
- Disallow a user to post in certain categories
- How to show custom message once on plugin activation?
- Article source link for posts
- Post source link plugin – small modification
- How to add users roles dropdown in registration in wordpress
- wp_schedule_event / cron_schedules – custom recurrence time not working in Plugin
- How to load a new template page according to a particular URL?
- WordPress network: set themes and plugins for new blog
- How to edit plugin’s html? [closed]
- Custom Post Type causes Page Not Found
- Can a plugin add to header/footer/body content?
- Organising the plugins folder in wordpress
- force customers to add only single item to card per purchase EDD [closed]
- Preventing BFA in WordPress without using a plugin
- Execute a plugin only on post pages
- How do I “get the next 10 posts after post_id == x”?
- Calendar Solution: Handling upcoming Dates with Posts?
- get_post_type on post.php
- Disable woocommerce cookies and delete cart data automatically
- Display by Category in Admin
- Why can’t I access my Intranet LDAPS with NADI?
- Setup page on first login on multisite
- Login Customizer doesn’t change the background of the register form
- Integrating WP E-commerce plugin into custom theme
- Is it possible to send blog posts via email to subscribers?
- Is there any plugin which can paste a common content to my every post?
- Custom post types – remove default post supports through empty array?
- When I try to de-activate any plugin it gives error “Warning: call_user_func_array() [function.call-user-func-array]”
- check uncategorized category by default
- I want to filter my products with attributes [closed]
- Action on WordPress Install
- What hook can I use to modify custom post data before it is displayed on the page?
- get current page number with wp_link_pages()
- Plugin is creating posts twice
- How to write a new file when new post has been published in WordPress
- What is the best way to make a custom page from a plugin?
- How to Get Recent 5 post in My Title bar?
- Plugin for visitors to edit content without logging in? [closed]
- WP Insert Post If user refreshes override new post
- Summary and Comments on Main landing Page
- Method/Plugin/Hack to Start a Post with an Writing Outline?
- Automatic recurring payment using YITH subscription and Dokan Stripe
- How to customize maintenance mode notification in wordpress?
- Oops! That page can’t be found
- Hide fields in woocommerce settings
- implement custom roles in custom plugin
- WordPress is redirecting me to homepage
- Adding custom post category to categories widget
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- Cron job shedules replace?
- How to wrap image tag into div for post only?
- Customize plugin templates
- Widget display in theme
- How to use custom footer template in a site-plugin?
- My own metabox checkbox plugin only saves the last value I’ve checked
- Customize a widget position
- Why the output of an image gallery plugin is not displayed into a page of my custom theme?
- Ger posts from similar tags and categories
- single.php fires more than once after clicking on any post to view with different post id each time
- Twitter List Tweets and Delicious Links as Posts
- Pronamic Info Window
- How to make only selected posts appear on a selected wordpress page
- How to block external download link access if visitor not referred from WP?
- From a legal perspective, is it okay to customize a plugin’s code?
- Child Plugin Admin Panel
- Notifications Bar on home page only
- Distribute post content through several divs [closed]
- Create Custom Coupon Type
- Using ACF to allow user to add and edit multiple saved forms
- Getting 400 Error in wordpress website