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
- Add a custom text to admin footer in a Custom Post Type page
- 4 column-loop ordered alphabetically with entries grouped (and labeled) by their first letter
- Tag page only display 10 posts
- category page for custom post type
- custom post type vs. conditionally displaying meta boxes for specific terms?
- Multiple single templates?
- data-type=”” … needed post tags stripped of characters
- Is there something like has_no_term
- Get only used meta_values
- Getting the taxonomy
- Template files for Custom Post Type and Taxonomy
- Custom post types: change “read more” text
- How to automatically and randomly reorder custom post type?
- Get post_type by term_id
- Set templates for custom post types
- How to keep a CPT from being visible on the front end?
- Ascending Order is not Working in Custom Post Type Listining
- How can i display movies in profile page, added by an user?
- Add a ‘guide’ image to custom post type admin page
- wordpress remove views from action links in a custom post
- Creat new admin url for custom post type
- How to Create Template File for Parent Page of Custom Post Type
- List custom posts
- Understanding Post Formats/Custom Post types Etc
- Edit the_content() function so to add a div wrapper
- If Post Meta Equals Current Title Conditional Advanced Custom Fields
- Extracting Address from Custom Post via Javascript for Google Maps API
- Post-thumbnail only for specific post-types?
- Custom Post Types — $args vs. labels array
- Serial Number Delivery System Using WordPress
- Custom Field values not Showing in Edit Page of Custom Post Type
- the_post_thumbnail call removing li in code
- How to make WP_Query not to show irrelevant posts?
- Custom post type causes php-error in php version 5.2.17
- When should I create custom post types?
- in_category for custom post types
- How do you create %post_type%/%postname%/ permalink structure?
- How do you make a custom post type items automatically delete items 3 months after publication?
- sort post types by amount of views
- Custom Post Type Dilema – How do I categorise by country?
- Creating my own portfolio custom-type
- Problems with 404, .htaccess, permalinks and WordPress custom posts locally on Snow Leopard
- Changed permalink structure of CPT – should I redirect?