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]
- WP_Query Pagination on single-custom.php
- Restrict custom post type to only site administrator role
- How to force one column layout on custom post type edit page?
- WordPress REST Create Post of Custom Type
- Limit the post for differents custom post type in the same wp_query
- taxonomy list display custom post count
- Is it possible to insert text into an html tag using functions.php?
- Assigning a role to a specific custom post type (and ignoring other post types)
- Display posts in random post types
- Custom Post Type by user
- How to create posts (not post template) to be displayed on projects page?
- WordPress Rest API only returns content when posttype has editor capability
- How can I show a custom post type for users in the authors.php file?
- Blog page showing same content as homepage
- Auto-generated posts not showing in backend (but being counted!)
- Need help targeting a custom post type with conditional tags
- Adding dropdown select meta box to custom post type – seems restAPI is interfering
- Is possible add class for last post of Custom Post Type?
- Show the same Article Available in Other Categories
- Push metadata in array
- Show custom post type filtered by category
- Display random posts, but omit the post it is on?
- Disable block with taxonomies at post page
- Get latest 3 posts from multiple CPT in one query
- Meta query for custom post type ignored in main query
- Hiding posts by other users and non-logged in
- Get related posts of child term of custom post type
- 2 Different Custom Post Types in Submenu
- How to assign classes to all elements?
- How can I show 1 featured post in a styled element, and the next few below differently styled
- wp_insert_post wrong post type [closed]
- Can I change my post type to anything and my site still work?
- Displaying custom post types as a gallery
- Get data from PHP to JavaScript to set position of each post on front page
- display posts of custom post type with custom taxonomy
- How to Query in WordPress which shows Alphabetic Posts?
- Post Query not working
- How to filter url on post submission?
- Different structure/content for posts from a custom post type
- creating files for displaying different custom post type posts with paging
- is it possible in a custom post, create custom fields as well whitin?
- Loading multiple post content in FancyBox
- custom taxonomy listing returns no posts
- How to controll the Posts post type and general wondering about WP data structure
- Display author box on just certain category posts?
- How to fetch posts that are stored in the different table than (default) wp_posts?
- Am I mixing up the concept of posts pages and categories?
- Display custom post counts for author , not default posts
- Building a Data Intensive Website with WordPress
- If/Else child list for Custom Post Type single template within loop?
- redirect after submiting post for review
- Display all Categories except ones with a specific parent
- How to achieve a multi-taxomony layout with posts?
- How can I put content before my custom post type default pages?
- i need to have a tab with gategory post
- Custom Post type to Woocommerce Product type
- How we can create menu from Appearance > Menu and use as a add-submenu-page for admin menu?
- Enforcing a rigid reusable template structure for similar posts?
- Auto delete pages/posts without views
- WordPress retrieving $post based on random key in $_POST
- dynamic vue widget inside custom post
- minimize wp_query call to database
- Post display in separate page [duplicate]
- User Archive page for Custom Post Type – Pagination Issue
- Limit posts per page depending on the size of a div?
- Delete Post by User
- Custom post Query and WordPress Post Query Clash
- Setting up a page to house certain types of posts
- Multiple Custom Post Type with different Taxonomies
- Links Image in “Catalog” Page to Posts
- Only show current category post
- WordPress Contents Migration
- Filter By Term Not Working – Custom Post Type
- Problem to get the link of the default ‘post’ post type like the orther custom types
- how to display notifications in the wordpress menu when a new post is published
- Editor role isn’t seeing specific post type posts with only post_type parameter
- Featured image in custom post is being disabled
- How to set class to “current-page” on the currently viewed single post within a CPT
- Getting wrong ID
- How can draft post after 1 year
- How to make post page unique and show it on home page?
- How to create content automatically when a post is published?
- query_post causes the posts to be loaded twice on load more posts
- Query Only Show Text on Posts With Certain Taxonomy Tag
- Query Posts From Multiple Post Types
- WP Build-In Post selector for CPT
- How to make a template for a specific post of a custom post type?
- How to hide home title on pages and posts?
- Woocommerce product page is not showing custom css [closed]
- How do I hide single category post on my post page
- Front end post or photo or both
- Can WordPress show posts based on a button that the user clicked 2 pages back?
- Two pagination in one page without AJAX
- Change post-name when inserting new Post if Specific Category is selected in WP