Avada Forums Community Forum How to run an Avada action on a specific page?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • malymarketing
    Participant
    Post count: 16

    I’m unable to get the following action to run on a single page. Both will successfully run the action when placed in the child theme functions file, but on ALL pages, rather than the specific page I want. Any thoughts on why this isn’t working? I’ve tried the two following snippets, the 2nd based on code provided by Avada support, but it doesn’t work either.

    if ( is_page( 5 )  )
    add_action( 'avada_before_main_container', 'avada_add_headerimage' );
    function avada_add_headerimage() {
        echo '<img src="/wp-content/uploads/2018/12/NPSC-hero-1300.jpg" alt="" />';
    }
    if ( is_page( 5 ) ) { ?>
    <?php
    }
    add_action( 'avada_before_main_container', 'avada_add_headerimage' );
    function avada_add_headerimage() {
        echo '<img src="/wp-content/uploads/2018/12/NPSC-hero-1300.jpg" alt="" />';
    }
    malymarketing
    Participant
    Post count: 16

    This has been figured out. Here’s some code that works in case anyone needs it:

    add_action( 'avada_before_main_container', 'avada_add_headerimage' );
    function avada_add_headerimage() {
    if ( is_page( 5 ) ){
    echo '<img src="/wp-content/uploads/2018/12/NPSC-hero-1300.jpg" alt="" />';
    }
    }
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.