I just posted an answer to another question about how to do it.
In your case, assuming you used body_class()
in your theme, your home page should have a <body>
with class home
to it.
So in your JS, you can:
if( $('body.home').length ){
// Do stuff
}
Related Posts:
- Custom post type and body_class: Remove “blog” class
- Storing posts from query and accessing later via AJAX call
- JS innerhtml changing style when using AJAX
- Side effects of Script and Iframe in post
- Redirect to another page using contact form 7? [closed]
- Posts are not rendering perfectly [closed]
- Passing total post count to javascript
- Default post showing more than intended
- Ajax load more post button not showing
- How do I check if a posts status is set to draft or pending?
- Change Post Title Edit Box
- Multiple Content Block
- Display Custom Post Type in Recent Posts
- Adding Custom Taxonomy to WordPress default Post type
- Multiple information using custom post type
- wp is not defined error using wp.media to create a custom image uploader
- IF statement in a do_shortcode
- Disable feeds for specific custom post types
- Get all posts WHERE custom_field is LIKE value
- Post type hierarchy
- Get the post children count of a post
- Disabling post_type in URL
- Quickest way to get last or oldest post date – WP Query
- Slug for standard post post_type
- WordPress Rest API only returns content when posttype has editor capability
- How to delete all posts from a custom post type?
- Make `previous_post_link()` Function Show The Post After Next i.e. Jump A Post
- Before Delete Post
- How do I create an archive page for standard posts?
- How to use custom fields to enable sticky posts on custom post types?
- Update content of multiple pages/posts at once?
- Display types of posts in edit.php instead of All, Published, Scheduled and Draft
- Making pages also serve as taxonomies? Or give full pages to taxonomies?
- Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?
- get_queried_object error How to show post count by month in the taxonomy page
- Check Title Unique Or Not and If not error message and dont save
- I am having a problem with form updating/editing WordPress post on the frontend
- How to filter the taxonomy terms based on another taxonomy term
- Remove parent from custom post type
- CPT’s archive and single page not working [closed]
- Add the current menu item CSS class to a custom page type archive in WordPress menu
- How to create A-Z index listing for custom post types?
- How to make post sticky in the admin page?
- different template for first and second level custom post page
- get_template_part for custom post type content not working
- Remove All, Published and Trashed Post Views in Custom Post Type
- Loop on front-page.php
- Custom Taxonomy – Tags Metabox is showing instead of Categories
- Why my custom post posts aren’t showing (404 error / page not found)
- Automaticly add slug to posts
- How to post twitter like updates on wordpress
- Show Two custom Post type and their posts on category page
- Change post featured image on hover
- WP_Query is printing out only one post when posts_per_page is set to multiple
- Trying to edit the single page from a Custom Post
- How to Submit Post Via cURL & PHP
- How to get all posts except for one post from a certain custom post type?
- count_many_users_posts except current logged in user?
- How can I show a custom post type for users in the authors.php file?
- Blog page showing same content as homepage
- apply filters only to specific post listing without check the url parameters
- How Can I Set the Post Author of a Post I Just Created With PHP?
- WordPress Orderby Numeric Value Not Working
- Exclude child pages from archive.php
- is there a way to retrieve posts that do not have a featured image assigned?
- Auto-generated posts not showing in backend (but being counted!)
- Shortcode for display posts on home page show only one post
- Deleting Custom Post type data using mySQL command
- Find the user who initially created the post
- Need help targeting a custom post type with conditional tags
- How to get the post type from a category id?
- Notice: Undefined index: suppress_filters
- How to Separate CPT From Regular Posts?
- Remove rows in the manage post/page view
- Is there a way to have the view link on manage posts page to open in a new window or tab?
- Open div inside a custom post-type with Fancybox
- Very simple wordpress block to display posts from an api call
- How to create custom boxes with text inside?
- How to get the parent of a non-hierarchical custom post type being edited in Gutenberg
- How to add post_type=value when editing that post type in the WordPress admin?
- Adding dropdown select meta box to custom post type – seems restAPI is interfering
- Open Custom Post Type as PDF
- Is possible add class for last post of Custom Post Type?
- Using The REST API How To Pull All Custom Posts?
- How i can add ‘N’ page of ‘N’ pages under posts loop?
- Show the same Article Available in Other Categories
- Getting posts under the custom post type ui category
- If post has custom field then display css-class
- Push metadata in array
- Display only one post each WEEK
- List children on child post
- Restrict custom post type from appearing with ?post_types=
- Show custom post type filtered by category
- create parent post using wp_insert_post
- Turn on and off custom post type from admin?
- Missing Posts in Custom Taxonomy List
- Display random posts, but omit the post it is on?
- Customize my custom taxonomy table in Admin panel
- How do I do this with WordPress? Taxonomies?
- Disable block with taxonomies at post page