I feel like I’m missing a lot of context from your question. If you are only asking how to execute a script on the homepage (and not on other pages), you can use the is_front_page()
function. You can wrap your entire script in an if statement
, like below:
<?php if ( is_front_page() ) : ?>
YOUR SCRIPT HERE
<?php endif; ?>
Check out https://developer.wordpress.org/reference/functions/is_front_page/ for more detailed information about this function.
EDIT
To only show the message on the front page, but keep the rest of the code on all other pages, you can simply wrap the message part in your conditional. Check out below:
<div id="cursorz">
<?php if ( is_front_page() ) : ?>
<div class="message" id="mess">Look at you! You look beautiful today!</div>
<?php endif; ?>
</div>
Related Posts:
- Could the WP script/style loader be used to concatenate and gzip scripts and styles in the front-end?
- wp_enqueue_scripts, wp_register_scripts, wp_print_scripts: i’m confused
- How to combine multiple CSS files and concatenate JavaScripts if WordPress recommends enqueuing them?
- How to solve ‘Eliminate render-blocking JavaScript and CSS in above-the-fold’ content for multiple files?
- WordPress Displaying Thumbnails Vertically
- Changing Font-Size based on specific Font thru javascript
- Collapsible button inside a ul list does work in jsfiddle but not in WP
- Relative path instead of absolute for wp_enqueue_script
- Handling URLs in WordPress application
- Can “ and “ tags be used in the HTML editor?
- JavaScript added as link/stylesheet
- Write text below a specific part of a sentence
- WordPress on localhost working, when sharing IP to connect receive err_connection_refused on .js and .css files
- Show enqueued CSS and Script in custom header
- How to insert html/css/javascript code to wordpress plugin
- Eliminate render-blocking JavaScript and CSS in above-the-fold content
- Older isotope portfolio rows shifting downward by 1 pixel on hover
- How to integrate my HTML and javascript into my child theme
- Shrink Header Image on Scroll
- How to create fa-bars animated menu
- Does costum code in the root folder get lost when wordpress is updated?
- CSS Minification
- Why is this jquery / java script code not working in mobile / in devices?
- Seperate functions.php for part of site
- How can I get the search form to be selected automatically?
- Implementing a simple slider in code?
- Cannot set property ‘className’ of null at setThemeFromCookie
- How to change “““ to “““?
- Conditionally enqueue a stylesheet based off of a javascript click event
- get_template_directory_uri() generates wrong path
- Remove CSS & JS from
- enqueing Javascript and CSS
- How to Add a Read-only Textbox With Text in it That Has a Button to Copy it?
- ACF Pro with SlickJS [closed]
- Show/Hide Div for Login Mask
- prevent HTML output if custom field is empty [closed]
- Plugins not showing up for custom template
- Equal height sections in custom Headway Theme
- W3TotalCache and Javascript — what should go where, when?
- How would I create the same popup in css and javascript as the one in contact button on the site https://www.sublimotionibiza.com/es/main.html [closed]
- Combine CSS Files without plugin
- Button doesn’t work in the profile panel
- WordPress Rest Api access the header and extract stylesheets URL
- Invert porfolio item order
- Embed widget from external source (Zendesk)
- Hide Tab Titles from Tabs Block
- How can I hide this custom slider while Elementor editing window is open?
- broken internal JavaScript and CSS files
- Getting and setting CSS variables with JQuery in WordPress backend fails
- Unable to use Datepicker in a table when inserting a row
- How to properly hide the div of an inline collapsible button?
- Change the version of default style.css in wordpress
- Web Developer Console: “Slow network is detected.” with fonts
- Enqueue CSS and Script only if needeed
- How to display javascript banner in website header?
- How would I add this code to a single WordPress page?
- The placeholder text doesnt disappear
- Trouble with adding preloader to my home page index.html and index.js
- Import HTML code that loads css and javascript into specific page
- How to implement a JavaScript and CSS file for my WordPress homepage?
- What can cause JavaScript and CSS files to be minified?
- Bootstrap 4 Optimization
- Move main menu to top of screen
- How to remove audio player styles added by mediaelement.js JavaScript?
- Interactive maps in wordpress
- Can I upload my HTML/CSS/Javascript game onto a WordPress page?
- How do I add JS and CSS to WP (Flatsome)
- “Plate” theme broken after update
- css transition opacity fade background
- Text-decoration: none not working
- How to center HTML5 Videos?
- What is the difference between visibility:hidden and display:none?
- Embedding a Square Appointments script into a WordPress site – it’s rendering fullscreen in the preview pane, so I can’t edit other content. Thoughts?
- Local wordpress install only shows home page, all other pages Not Found
- raw code vs wordpress
- Only column gallery on mobile device
- show count is out of the anchor tag in wp_list_categories
- Why won’t my custom login page CSS load?
- NGINX+wordpress: CSS being served but not applied
- Menu toggle bar works only on some pages in WordPress
- Including CSS files in HEAD based on page content
- Video header on mobile, disappears behind header and content
- Free theme and css/bootstrap.css is not overridden in the child theme
- How to style text in WordPress
- Links on the page, when being printed, have the URL next to them
- How do I minify ‘@import’ css files with wp-minify?
- Selector for page to set up scrolling plugin
- Type character in name and make it invisble
- Hide product variations at home page
- TinyMCE on frontend style not working
- H2 On Blog/Article Page Gets Assigned a Class
- WordPress Slider is not working
- HTML not resizing
- CSS in child theme to replace !important in parent theme
- WP theme update causes child theme CSS problems
- Which files can be replaced in a child theme?
- How do i make a sidebar background color? [closed]
- Twenty Fourteen Theme – Moving left sidebar to the right
- WordPress doesn’t respect “ver” parameter in styles [closed]
- how to change the colour of this background