I’m at work at the moment (sorry boss), so I can’t test this, but the snippet below should be the proper way of testing if the ‘featured_post’ post type exists, and then enqueue the script if it has any posts.
if ( is_front_page() && post_type_exists('featured_post') ) { // We are at the front page, and the post type 'featured_post' is registered.
$hasposts = get_posts( 'post_type=featured_post' ); // lets check if there is any posts in the 'featured_post' post type.
if( $hasposts ) { // If we found some posts, lets enqueue the script
wp_enqueue_script ('flexslider-js');
}
}
Related Posts:
- How do test if a post is a custom post type?
- How to enqueue scripts on custom post add/edit pages?
- Load a script just to custom post type in admin
- Conditional for single-{post-type}.php
- is_singular() not working if called via callback function of admin-ajax.php
- functions.php conditional tag only for custom post type
- Exclude custom function content from certain pages
- Get template part based on custom taxonomy term
- If on term-page -> get the current term?
- custom post type upcoming post and past post
- changing default comment form arguments [duplicate]
- How to localize value of posts
- is_page_template not working as expected
- remove child post from custom post type archive
- Trying to add script to specific admin page is not working
- Need help targeting a custom post type with conditional tags
- Why would this IF statement not work? [closed]
- custom comments on specific post type
- Excluding custom post types
- Enqueueing scripts and styles multiple CPTS
- Register widget only page is a singular of custom post type
- Is there a conditional tag to determine whether the post is _any_ custom post type?
- Conditional Query of Custom Post Type and custom taxonomy
- How to run filter only on custom post type edit screen
- Conditional statement for if archive page has posts which contain certain taxonomies/categories/tags, show those terms
- Custom Post Conditional for Parent & Child Single.php?
- Conditional for a Single Post That Belongs to a Category?
- How to show only the most recent post on my custom post type archive?
- Conditional Tags for specific category of custom posts
- Move Genesis Single Page/Single Post Title
- How to check if post/page or taxonomy post is published by admin
- TinyMCE Buttons on Certain Post Type
- custom fields cannt be seen with version 3.1
- Display message if no posts in Custom Post Type loop
- Showing taxonomy terms on custom post type
- Check if custom post is a parent?
- Enqueueing TinyMCE
- Redirect to URL if x number of days passed
- comments hooks on custom post type
- Conditional Statements
- If custom taxonomy else conditional [closed]
- If tag exists, then echo once
- Show specific content on parent custom post type and all children
- Use conditionals with wp_enqueue_style to attach stylesheet according to post type displayed
- How can I check the rewrite slug of current post type listing page
- How to add custom PHP code in post header?
- $_SESSION Not working after X amount of page views
- How to make sure, that only the selected post is changing?
- conditional based upon the count of current user’s published custom posts
- Custom metabox fields not saving when limited to a certain CPT
- Can not hook into custom post type template with: is_page() conditional?
- Diffrent search templates for different post types
- Conditional Tags If Custom Post Parent & Child?
- Custom Post Query Combined with Conditional Tags
- Conditional statement checking two conditions for CPT and Custom Taxonomy [closed]
- strange conditional tag behaviour [duplicate]
- Custom post type is_singular condtional not working when managing sidebar display
- Submit post and upload image from front-end
- How to disable generation of default image sizes for some custom post types?
- Development of a WordPress Search Plugin – Best Practices
- Mini-Site Strategy
- Using Custom Fields in Custom Post Type URL
- How do I Filter Custom Post Type by Custom Taxonomy in the newest WordPress RESTful API?
- show tags of custom post type ONLY
- Hierachical Custom post types permalinks not working
- Why is the »_builtin« parameter not advised in »register_post_type()« for custom post types?
- Query posts by custom post type and custom taxonomy
- How to get current post id of a custom post type in a loop using template singel-{custom type}.php?
- get_template_part for custom post type content not working
- WordPress post count not showing for custom post type author
- Can I make WordPress use a custom template for a child page
- Open div inside a custom post-type with Fancybox
- Save metadata as a timestamp, display as a “pretty” date
- Can I search only some of the fields of a custom post type?
- Save the post parent in a custom post type in Gutenberg
- Dynamic template for single custom post
- Create another comment system for CPT
- menu link to custom post_type?
- Custom Taxonomy Not Showing in Front-End When Outputting a Custom Post Type with WP_Query()
- Adding custom field values to wp_list_pages
- Custom columns doesn’t appear in custom post type
- How to insert data into meta box from another plugin?
- CPT Taxonomy As Archive Page – Error 404
- Methods for development wordpress themes [closed]
- unapprove comments on custom post type
- Making a form for user to add new custom post with custom taxonomies and custom fields
- Custom post type pagination error
- Publish box in CPT remove ‘edit’ link
- How do I troubleshoot pre_get_posts with Debug Bar?
- How to only get the content of post page while looping?
- Delete Custom Posts & Attachments
- How to save post title before publish?
- order taxonomy alphabetical
- Custom post type archive page not showing on archive-posttype.php
- Implement post status update as frontend news announcement
- Custom Post Type Organisation – Taxonomies, Categories and Pages
- Expandable WordPress content (text) inside a post
- Custom Post Types and rewrite rules – One CPT works and a cloned one doesn’t
- Sort a custom post type loop by a custom taxomomy instead of chronologically
- I want to understand plugin implementation of custom posts / taxonomies / metaboxes