• Resolved msalsas

    (@msalsas)


    I’m trying to include a video background in the home page. I have a front-page.php file, which is executing in home page.
    So I’ve created a new page landing with the shortcode and then wrote in the front-page.php file:

    ...
    <?php
    $page = get_page_by_title('landing');
    echo $page->post_content;
    ...

    But I’m getting a JS error:

    Uncaught TypeError: $(…).vidbg is not a function

    I’ve tried with different things like:

    $page = get_page_by_title('landing');
    $content = apply_filters('the_content', $page->post_content);
    echo $content;

    but always get the same error. The only way to make it work is to go to the page itself. Am I missing anything or is this a bug?

    I’m guessing that the some script is not called.

    https://www.ads-software.com/plugins/video-background/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor blakedotvegas

    (@blakedotvegas)

    Hi msalsas,

    I would reccomend creating a function in your child theme’s functions.php file that adds the vidbg shortcode when the is_front_page() conditional is called. Here is an example below:

    /**
     * Create the function
     */
    function msalsas_vidbg_front_page() {
      /**
       * Check if the current page is the front page
       * If so, init shortcode
       */
      if ( is_front_page() ) {
        do_shortcode( '[vidbg container="body" mp4="#" webm="#" poster="#" muted="true" loop="true" overlay="false" overlay_color="#000" overlay_alpha="0.3"]' );
      }
    }
    /**
     * Add this function to the WordPress footer
     */
    add_action( 'wp_footer', 'msalsas_vidbg_front_page' );

    That javascript error worries me though. Could you link me the page that is experiencing this issue?

    Regards,
    Blake

    Thread Starter msalsas

    (@msalsas)

    I finally found the problem. I was not including get_footer(). If I do, it works as expected. Thank you anyway

    Thread Starter msalsas

    (@msalsas)

    Resolved

    Plugin Contributor blakedotvegas

    (@blakedotvegas)

    msalsas,

    I’m glad you found the issue.

    Have a great day!

    Regards,
    Blake

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Use in home page’ is closed to new replies.