Js Load on Page Based

PHOTO EMBED

Thu Jul 06 2023 11:52:06 GMT+0000 (Coordinated Universal Time)

Saved by @gshailesh27

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');
content_copyCOPY