Skip to main content
Edit tags
Link
Dave Romsey
  • 17.9k
  • 11
  • 55
  • 70
edited title, added more detail
Source Link
Laxmidi
  • 971
  • 4
  • 19
  • 37

How to include code only on specific admin pages?

I'm learning about plugins and shortcodes. I noticed that when I activate my plugin its code gets loaded on all of my pages-- even pages that don't have my shortcode. How(I don't mean content vs. admin pages). On some content pages, I use a particular shortcode and on other content pages, I don't-- but in any case, the plugin's code is loaded. How do I make it so that the the plugin is included only on pages where the shortcode is used?

More Detail:

Let's say I've got a plugin that makes a lightbox. I activate the plugin. On my "Cool Images" page, I use shortcode to make a lightbox. When I check View Source on my "About" page, which doesn't use the lightbox shortcode, I see that the lightbox plugin's code has been loaded. My pages will load faster if I write my plugin so that its code is only loaded on the pages where it's needed. Is this possible? Otherwise, I'll have code for lots of plugins loaded on pages unnecessarily. Any ideas?

How to include code only on specific admin pages?

I'm learning about plugins and shortcodes. I noticed that when I activate my plugin its code gets loaded on all of my pages-- even pages that don't have my shortcode. How do I make it so that the the plugin is included only on pages where the shortcode is used?

How to include code only on specific pages?

I'm learning about plugins and shortcodes. I noticed that when I activate my plugin its code gets loaded on all of my pages-- even pages that don't have my shortcode. (I don't mean content vs. admin pages). On some content pages, I use a particular shortcode and on other content pages, I don't-- but in any case, the plugin's code is loaded. How do I make it so that the the plugin is included only on pages where the shortcode is used?

More Detail:

Let's say I've got a plugin that makes a lightbox. I activate the plugin. On my "Cool Images" page, I use shortcode to make a lightbox. When I check View Source on my "About" page, which doesn't use the lightbox shortcode, I see that the lightbox plugin's code has been loaded. My pages will load faster if I write my plugin so that its code is only loaded on the pages where it's needed. Is this possible? Otherwise, I'll have code for lots of plugins loaded on pages unnecessarily. Any ideas?

Tweeted twitter.com/#!/StackWordPress/status/156291025265115137
edited tags; edited title
Link
kaiser
  • 50.8k
  • 27
  • 150
  • 244

Plugin Code Included How to include code only on All Pages-- Not Just the Ones Where I Used My Shortcodespecific admin pages?

Source Link
Laxmidi
  • 971
  • 4
  • 19
  • 37
Loading