function load_prd_picker_script_based_on_post_id() { // Get the current post ID $post_id = get_the_ID(); // Specify the post ID where you want to load the script $target_post_id = 2318; // Replace 123 with your desired post ID // Check if the current post ID matches the target post ID if ($post_id == $target_post_id) { // Output the JavaScript code ?> <script> $('#clearButton').on('click', function() { for (let eachFilter of filters) { eachFilter.classList.remove('active'); } for (var project of projects) { project.style.display = "initial"; } noDataMessage.style.display = "none"; }); }); </script> <?php } } add_action('wp_footer', 'load_prd_picker_script_based_on_post_id');
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter