to be able to identify a specific “post” you need to have some unique attribute in its HTML. Usually the easiest thing to do is to use the post id as part of the id
attribute (in your case maybe something like overlay{$post_id}). I personally started to prefer to use data-
style attributes instead but for this use case the difference is more of esthetics than anything else.
Now that you have everything unique (and maybe even instead of doing that at all), either use a common class on all the “posts” and have a handler for click on elements with that class (easy with jQuery), or add a click handler on the containing div
instead of the elements, and in the handler look at the event properties to find out which “post” was actually clicked.
Related Posts:
- WordPress Admin Bar pushed Sticky Footer off the bottom of the page
- Is it possible to use the featured image of a page as a css background without inlining?
- Minify HTML, CSS, JS with PHPWee?
- Archive dropdown styling not applied
- An unwanted inline style is added to my body tag
- Show post in slider
- Slider loading issue
- I have a problem in the order of enqueues while enqueuing stylesheets and scripts for a specific page in my function.php
- Incorrect MIME type for assets with Valet
- How does wp_enqueue_scripts work?
- Add Codepen animation as Preloader to WordPress
- trouble with page_id & highlighting current page
- wordpress admin plugin menu custom css
- How to add drag and drop functionalities to a div inside option panel
- Removing WordPress Footer -without access to PHP code?
- How to Change CSS Colors from Custom Plugin Settings Page
- Link to page with posts of specific type
- How to add new CSS file to new PHP file
- How to sort posts by active category in WordPress?
- Integrate admin plugin into template. Very interesant (live search + autocomplete with wp rest api, in vanilla js)
- Add other class content with reference class value
- Run do_shortcode on php template using JS function
- How do I integrate vanilla Javascript to a wordpress website?
- Google CSE Malfunctions via Chrome/Safari on Mobile When Clicking on Either Search Icon/Menu Icon. How to Make Google CSE Default Theme Search
- I have a lot of JavaScript erorrs after SSL someone can help me?
- WordPress Slider is not working
- register dependency css and js inside a plugin class
- Bring Font Awesome icons inside menu A tags
- custom field – changing an element or background of id div – different versions not working
- Target a specific container to style on WordPress storefront theme
- Where to find the html for WordPress site? [closed]
- Trying to customize wordpress drop down categories
- How to create and add js and css file when server is not on my PC?
- WordPress Infinite Scroll without using any plugin
- WordPress Ajax always returns a 404 error
- Conditionally loading JavaScript based on the Advanced Custom Fields in the post
- How to change “Shipping Calculator “field label on Cart Page – woocommerce? [closed]
- Is there a reason why my wordpress PHP page isn’t loading into my PHP template
- How to resize image on client-side before upload?
- Limit the Excerpt field in WP-Admin in words
- Audio Player not loading when the content is loaded through Ajax, MediaElement.js no applied
- Customizer Show/Hide Logo and Site Title
- Use different javascript files for each page on website
- Categories Template Assistance
- Put CSS inside a PHP file and include it the right way
- Sending jsPDF documents to the server
- js file in root loading without
- How to use my style.css file outside of wordpress subdomain?
- Displaying admin notices inside the block editor from rest_after_insert_{$this->post_type} hook
- wordpress visual composer change grid builder post link
- PHP array to JS array to use in google map
- How to add a Custom Mailchimp AJAX Newsletter Subscribe Form
- Fancybox type popup window that’s not an iframe
- how to make my website secured
- proper way to add css using functions.php?
- RTL Stylesheet Confusion with WordPress
- element not working in Safari [closed]
- How to make container class in PHP
- How to call multiple functions from multiple files into a WordPress page template [closed]
- PHP in CSS file?
- Last class on last headline?
- An audio player that showcase a random song from playlist every 24h [closed]
- Can I set up a hover animation in CSS depending on a PHP conditional?
- How can I get “Previous” and “Next” to show in the navigation besides the links?
- url_to_postid returns 0
- How do i add slugs to a URL, but still redirecting to the same page
- implementing a jQuery “click to expand” link in WordPress [closed]
- php loading different structure than source code
- random reason on refresh
- Change Query Arguments (filter) with jQuery/Ajax or PHP?
- Some problems in custom widget
- Call a function in functions.php from within tags (JS)
- Displaying images outside the content
- Tracking Visitor LatLng with WordPress using JS, PHP. How to put data which was extract using JS into DB
- WordPress Search Ajax + Isotope + InfiniteScroll
- WordPress User Meta value variable into Google Gauge Chart
- Require()/Include() post template adding extra content
- PHP function for horizontal Woocommerce thumbnails and badges
- How to call my PHP function with AJAX ? wp_query
- My top header looks different on single pages but is fine on the home page
- Using php code inside style tag
- How to pass values from one function to the other using an array variable
- dynamic php menu with hidden sub-categories only showing when the category name is clicked
- separate list of programs in html/javascript coming from php
- How to print all the inline styles in the WP_Styles instance together with their keys?
- The style.php file inside theme-engine folder has other content on FTP
- Site title not showing. Please help me
- How to display last whole post on the homepage
- ACF + WP + Slick Slider Repeater Slide Group PHP not Displaying [closed]
- Add point on excerpt post
- Custom Theme, Editor won’t wrap text (i.e. change width)
- customizer live preview layout picker
- Click to expand menu
- WooCommerce – Print Processing orders [closed]
- Loop returns more items than exist?
- If I define a variable in header.php, how do I make it available to templates?
- New to wordpress. Need Help with templates [closed]
- JSON Object Value Show Undefine
- WooCommerce Checkout Cart [closed]
- How can I use AJAX in child theme template?