• Generosus

    (@generosus)


    Good Day,

    Is there a way we can modify the code snippet given below such that it applies not only to our main ‘blog‘ page, but also all subsequent paths? For example, /blog/our-new-widget and /blog/making-plugins-better. We can confirm ‘blog/*‘ (using a wildcard) does not work.

    Thank you!

    function change_avada_privacy_label() {
    if ( is_page( array( 'news', 'blog', 'events', 'contact' ) ) ) {
    ?>
    <script type="text/javascript">
    // select all elements with the class name "fusion-privacy-label"
    var elements = document.getElementsByClassName("fusion-privacy-label");

    // change the innerHTML of each selected element
    for (var i = 0; i < elements.length; i++) {
    elements[i].innerHTML = "For privacy reasons, we need your permission to load our content.";
    }
    </script>
    <?php
    }
    }
    add_action('wp_footer', 'change_avada_privacy_label');
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Absolutely, you can use the get_post_parent() function to work this out:

    function change_avada_privacy_label() {
    $parent = get_post_parent();

    if ( is_page( array( 'news', 'blog', 'events', 'contact' ) ) ||
    $parent && 'blog' === $parent->post_name ) {
    ?>

    rest of code here
    Thread Starter Generosus

    (@generosus)

    Thanks for that! Unfortunately, it did not work for us.

    Below is the code we used. Can you give it a second look?

    Again, thank you!

    function change_avada_privacy_label() {
    $parent = get_post_parent();

    if ( is_page( array( 'news', 'blog', 'events', 'contact' ) ) ||
    $parent && 'blog' === $parent->post_name ) {
    ?>
    <script type="text/javascript">
    // select all elements with the class name "fusion-privacy-label"
    var elements = document.getElementsByClassName("fusion-privacy-label");

    // change the innerHTML of each selected element
    for (var i = 0; i < elements.length; i++) {
    elements[i].innerHTML = "For privacy reasons, we need your permission to load our content.";
    }
    </script>
    <?php
    }
    }
    add_action('wp_footer', 'change_avada_privacy_label')
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.