functions.php
is part of the loading process and way too early for conditional tags to work reliably. Any conditional logic should be hooked to and executed no earlier than template_redirect
hook.
For scripts on front-end wp_enqueue_scripts
is appropriate hook.
Related Posts:
- WordPress function like is_category for subcategory? is_subcategory?
- deregister scripts on certain page
- is_front_page not working in functions.php
- disable comments if array exists
- Problem using is_single() to enqueue script from functions.php
- Conditional tag is_page with a custom post type
- Limit posts only on home page – ideally in functions.php
- Enqueue scripts not working with if is page conditional tag in functions.php
- Conditional read more adjustment
- How add various functions within 1 conditional?
- Conditional Gravity Forms filter in WordPress Multisite
- Has is_archived() for sites in a multisite changed with WP 4.7?
- Testing for a shortcode using a function. 404 page throwing PHP Notice
- is_page() or is_single not working
- issue with if/elseif in_array inside foreach loop display only one post
- Set “woocommerce_is_purchasable” to false for specific “$product->is_stock_status”
- Entirely Different Functions.php per Page?
- Function to echo (or display?) wordpress tags in the head section
- is_home() not working in functions.php file
- If is_single in functions.php
- Enqueue script if not page template
- is_product_category(‘Services’) not working
- method to fetch entire tag list on archive.php
- Adding an IF ELSE to a function
- how to display featured image for single post for a specific category
- Load CSS conditional on custom field is present
- admin-ajax.php nulls all php variables
- restrict access to specific urls on a specific period of time
- Change conditional tag in wordpress without editing the core files
- wp_enqueue_scripts called twice?
- How can i hide content if not friend in Buddypress? [closed]
- PHP Notice: Function is_page was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false
- Get the ID of the page a menu item links to?
- Add container to nav_menu sub menu
- One Child Functions.php for Multiple Child Themes
- Disabling pingback and trackback notifications
- register_post_type for Pages?
- Paged Single Post doesn’t redirect to the main url after Removing Pagination
- How to get comments with mixed status using get_comments?
- How can I rename the WordPress AJAX URL? [duplicate]
- How to add a rel attribute to images that contains their categories?
- Is it possible to be more page/post specific with admin_enqueue_script?
- What is the most efficient method for loading widgets in functions.php
- Enqueue script o style only if a template part is loaded
- Can I pass two roles to the function get_users?
- Add external js file to footer with id
- How can I enable uploading excel files?
- Change the HTML of the comment form that is generating somewhere from the core WordPress
- How to customly read JWPlayer’s “Playlist” items by using its “playlistid”?
- Twentyten Child Theme: header images display messed up in admin panel
- Removing wp_login_viewport_meta
- Get Current Post ID in functions php, meta query filter
- Move Custom Fields on General Settings Page to New Location
- Remove adjacent_posts_rel_link under 3.2?
- enqueue_script with filemtime javascript not working
- How to obtain the recent posts without their content in an efficient way?
- Limit dimensions of “Full” size images
- Where to put random functions?
- Define PHP variable from a seperate API if statement
- Auto-Tweet if Type is ‘Status’ using OAuth
- Function not working inside of a function in functions.php
- How to Use Global Variables Inside Header and Footer
- Redirect website domain (including all pages) to external URL after Popup message (few seconds)
- Where do I go to edit this area? [closed]
- Enable right click on WordPress site
- Check from functions.php if function exists in footer.php
- This code works, but the way I integrated it is breaking the media uploader. How can I integrate it properly?
- Email Exists ERROR into Ajax registration form
- How to overwrite template.php file
- Limit number of characters in different excerpts
- Facebook OpenGraph error, Call to undefined function wp_get_attachment_src()
- How to avoid saving empty data to sql while using add_meta_box
- How to assign php file(template) to several pages with same prefix page name/slug
- How to fix Function create_function() is deprecated in / themes
- Block all plug-ins from initiating redirection upon activation?
- How to display my comment count in the wordpress admin bar?
- custom error message for empty username and password using authenticate filter not working
- Modifying a WordPress Plugin
- I have an fatal error on my funcyions.php
- Get post_author email for Zapier Integration
- get_locale() is different from $locale
- If click on Save/Publish change Post Status to Pending Review instead Publish
- Remove all video attachment, both files and post/postmeta from database?
- Remove the delete link from pages without a plugin
- Custom download page
- How to include a hyperlink in the body text of a custom password protected form?
- Get title from IDs in a string
- uninstall a theme programmaticlly
- Dynamically generated Navigation Diagram using Custom Fields
- Update add_image_size
- Function to get the name in database table from the comma separated string
- Full size image option removing problem
- Limit length of headline in Editor
- Force resize for all video content
- Way of getting queried loop before the query with a filter hook?
- Why my wp_enqueue_script doesnt work on some page?
- Need to use an external variable inside a function
- Trying to get this function to show below the content
- Add functionality to block comment authors in the Comment edit pag
- WordPress enque the same script causes the setInterval not to work