function add_js_one_col_wpse_107240() {
if (is_page()) {
$pobj = get_queried_object();
if(!empty(get_post_meta($pobj->ID,'one-col',true)) {
wp_enqueue_script(/* ... */);
} else {
wp_enqueue_script(/* ... a different script ... */);
}
}
}
add_action('wp_enqueue_scripts','add_js_one_col_wpse_107240');
get_queried_object
will get you the page information. It will
be aWP_Post
object on a “Page”.global $post
should probably
work too, but this is cleaner.- Use the
WP_Post
object information to check for the custom meta
field. enqueue scripts accordingly. You don’t say what the value
ofone-col
is so I checked for any value at all. - Hook the whole thing to
wp_enqueue_scripts
.
Related Posts:
- Add infinite scroll to content splitted post
- Prevent WordPress from adding linebreaks to javascript embedded in a page
- What are the options for running custom css and javascript files on a page?
- Using JavaScript and JQuery in Page
- Backend option to include a javascript file on specific pages?
- WASM page in WordPress website
- Can I include Javascript/jQuery in a page?
- Add a predefined page to site
- Adding a Calculator to a WordPress Page
- JQuery Plugins in WordPress
- loading a javascript on a WP PAGE
- How To Render Shortcode In AJAX Response?
- Stop playing music (rev slider) when user opens new tab
- Press This for Page
- Converting HTML to WordPress theme: integrating pages function and using its text editor, conditional enqueuing
- Javascript will not run properly
- How to configure WordPress to handle 75,000 pages?
- How to disable posts and use pages only
- Create a “Dummy” parent page for a hierarchy in page listing?
- Password protected post or page – error message by wrong password?
- Get next/previous cousin page
- I want only my sub-pages to be clickable in the navbar
- How restrict page for users logged? [closed]
- How do I turn comments off for pages, but not posts?
- List Child Pages of Parent Parent Page (Child pages from Grand Parent)
- How to add meta boxes to Pages
- Form action redirect to the same page
- How do I create a separate page for each author?
- Overriding the currently selected menu item
- WordPress pages with hierarchy
- How to incorporate Documentation into wordpress?
- Missing parent page attribute
- Hiding Page by Title from Editing
- Get page by its ID and display it on another one
- creating and styling a within a page
- What are trackbacks?
- How to enumerate a list of posts?
- How can I redirect to my custom page without loading the Dashboard itself?
- Remove ID page from wp_count
- category slug and page slug same
- New user Registration data imported into Page
- Could be a namespace conflict (?) with login form and register form on the same page
- Updated WordPress, now getting errors on site
- Edit Parent page drop menu when creating a page
- Get parent of current page
- How to list a page tree?
- Attachment pages stealing page slugs
- How to add an external php page with wordpress?
- Exclude pages by menu order
- WordPress pages not working out correctly with HTML
- Change page name in admin list
- How to exclude authors from get_pages()
- Folder wordpress page redirect
- Dynamic page with comments
- How to rewrite a page url
- Display pages in alphabetical order
- Get rid of “comment” field on non-blog pages [duplicate]
- Password Protect Pages Not Working
- Can I connect a page to a taxonomy?
- How to control display of page lists on sidebar that doesn’t have childrens
- wp_nav_menu: output featured image of each page listing
- Is there a template tag/function for getting the URL (or slug or name or ID) of the blog page when using a “static” front page
- Problems in creating a static site with WordPress
- Creating new page/tab in groups section not working! [closed]
- Change displayed “page name” to distinguish multiple pages with the same title
- add title to widgets of wordpress
- Custom user tables not working after migration
- remove “Edit” from select pages
- How to transfer a site to hosting?
- Add custom action to the page listing screen
- How can a .css file be applied to a virtual page?
- WordPress blog posts template bug [closed]
- Checkboxes to automatically create pages when I activate a theme
- Cannot update page – with too many characters?
- Is it possible to embedd this web app to my website [duplicate]
- Using external DB within wordpress
- Cannot use old slug – it just 301s to site home page
- Display inner pages like posts.[Like how post excerpt works]
- include exception inside theme for empty widget area
- My pages disappeared from the list
- Pre-populating new Page creation with shortcodes
- How to display time when page is created and edited
- Loading internal page
- Firing page_publish where page is child page
- Access wordpress pages using a self signed shared ssl
- Page loads all pages of the image gallery with pagination
- Group Pages based on Parent in Admin Area
- Google indexed pages for one page site
- How to exclude page in pages module
- get id custom tables on current page
- static page with buton that opens collect email form
- Parent for a single (single.php)
- Multiple WordPress Pages
- How to create an user defined page?
- How can one get page by pagename if it is a child page?
- Archive with specific keyword by category sorted by date
- How do I use (or mimic) document.getElementById() on a page loaded from WordPress database?
- Is it possible to keep the page title from actually appearing at the top of the page?
- Missing page on wordpress “Pages” dashboard [closed]