For scripts this is no-brainer – just enqueue inside my_gallery()
function and they will be output in footer (since header already passed).
However stylesheets are a challenge, they are only supposed to work in head
section and enqueueing for footer is not supported.
Essentially you need to know if function was called before it was called. This has no simple solution for conditions given.
I would probably try to load stylesheet from JS code to achieve this in form you are describing.
Related Posts:
- Pass post ID to JavaScript outside the loop
- WordPress get_posts function, 1300 lines long
- Exclude a category if post is only in that category using wp_Query
- Too slow when using both ‘tax_query’ and ‘meta_query’ both in WP_Query
- Use of caller_ get_ posts
- Tax_query terms ID’s using variable
- Get the list of enqueued/registered scripts for a specific post?
- Initiating WP_Query() with no args and adding them later through the query() method
- Pagination custom query
- WP_Query and name__in
- Order posts by tags count?
- Querying Multiple Custom Taxonomy Terms
- WP Query with offset breaks wp_pagenavi or any pagination
- Show list of authors with latest post NOT older than a month
- Unable to combine “search value” and “tax_query” using WP_Query
- How to extend tag and category “Related Posts” query to custom post_type if the first 2 terms have no posts
- Loading scripts & styles from a meta box callback function
- wordpress query in header won’t reset and corrupts other loops
- How add a custom posttype name using ACF field to a query post array
- WP User Query multiple AND OR query problem
- Php Trying to get property ‘ID’ of non-object
- More than 1 Year Date Query
- Is it possible to dynamically get queried term AND taxonomy?
- posts_per_page not working
- Pull post meta with post_query?
- How to use WP_Query to display many posts?
- How do I force WP_query to fetch fresh, non-cached results?
- Complex WP_Query (two post types and multiple operators)
- Five posts from a category in footer
- Remove category from query (show all posts in archive.php) pre_get_posts()
- Get and Trim Full Post Content in WP Query
- How to Union two different conditions in one WP_Query
- Display filtered results into custom page
- WooCommerce – get product sub categories
- Order by empty custom field
- WP_Delete_user link creation
- How to exclude post formats from wordpress recent posts in a tabs widget [closed]
- How to pass orderby params to $wpdb->prepare()?
- Get author if post has multiple authors
- how update data through ajax and jquery
- What happens to the default query when I use WP_Query?
- WP_Query arguments relation shows AND instead of OR
- Combine results of multiple WP_Query to resemble single WP_Query
- Modifing archive query affects show post count function
- Using WP_Query() in Magento shows error
- How to use wp_enqueue_script, style when required
- For what queries is conditional tags informative?
- Utilising an existing page while using the “s” query parameter
- posts archive page – closing WP_Query loop correctly [closed]
- AJAX Breaking Offset Argument In WP Query
- Get meta_value of a specific meta_key from all posts belonging to a specific custom type
- Excluding posts with certain value of meta_key keeping posts without that meta_key
- Pagination in html table is not working
- Nested array issue in meta_query
- Function using get_posts() with tax_query not working when called from functions.php
- Why does WP_Query have methods that return public properties of the same name
- Understanding wp_enqueue_style
- Query by key or author
- Search for pages with permalink
- Don’t repeat posts from children in parent taxonomy query
- WP_query paged pagination with excluded category still counts it
- meta_query with array as value with multiple arrays
- Why doesn’t my WP Meta Query return any results?
- How to make the ‘request’ filter work?
- Filter for each loop when WP_Query has no posts to show
- Custom WP Query order function possible?
- How sort products by calculate value? ( custom post meta, price, option)
- wc_get_products() return empty object
- Pagination unique to a widget
- Ascending numerical sorting with non-numerical characters last
- WP_Query not returning custom post type
- How do I use $wp_query->current_post with get_template_part? I’m trying to add post classes (first/last/even/odd) to custom loops
- Why pagination is not working with tax_query param?
- Finding post ID dynamically on click
- paginate_links method doesn’t show second page of my custom wp_query
- ACF Post Object meta-query by title not ID
- Case insensitive ORDERBY in wpquery
- Sorting with meta_query and multiple, optional meta keys
- getting posts by tags
- WP_Query & Duplicate entries
- Query child posts with tax query on parents
- From admin edit user page query either the user_nicename or username field value of the user profile being edited or viewed
- custom search form, posts_per_page value being ignored
- how to fix loading scripts in child theme?
- Fetching $_POST from Page Template into functions.php
- Include post_status check within $wpdb query
- Return on a quest all these meta_value
- Inline Ajax call after term is appended with a @ or # etc. displayed in div
- Complicated WP_Query
- Passing conditional arrays to WP_Query() [closed]
- Query custom post type by date field only working when two posts match the query
- Why isn’t my Meta_Query running?
- Custom query to show posts
- How to specify a certain amount of images queried, not all?
- Carousel Loop only duplicating
- Taxonomy related query not working
- How to show featured post first, then separate loop for other posts
- error with $query->have_posts()
- Multiple Orderby is not working right
- Display only posts with thumbnails