• Resolved kegan5

    (@kegan5)


    I have a background video playing as a full screen background on all pages but I would ideally like the homepage version to play sound and for every other page to be muted.

    I assume I need to throw in an If Else statement here but I lack in php skills.

    I’ve read this thread here: https://www.ads-software.com/support/topic/change-background-image-per-page-1?replies=25 which implies the same method to change an image.

    However I’ve tried tweaking it to become an (if it’s the home page then don’t mute, else mute) but I keep getting php errors.

    First of all is it possible to control the video tag via the stylesheet to turn the mute on and off?

    If not, could someone point me in the correct direction?

    This is what I’ve been playing with:

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    <?php if (is_page('page-id-xx') ):
    	  // page-id-xx ?>
    	<div id="vid1">
    	<video autoplay loop style="position:relative; max-width: 100%;">
    		<source src="https://website.com/REEL.mp4" type="video/mp4" type="video/mp4">
    	</video>
    	<div class="vidcontent">
    
    	</div>
    </div>
    <?php else
    	  // all other pages?>
    	<div id="vid1">
    	<video autoplay loop muted style="position:relative; max-width: 100%;">
    		<source src="https://website.com/REEL.mp4" type="video/mp4" type="video/mp4">
    	</video>
    	<div class="vidcontent">
    
    	</div>
    </div>
    
    <?php endif;  ?>

    Any help would be really appreciated

Viewing 1 replies (of 1 total)
  • Thread Starter kegan5

    (@kegan5)

    After reading through various how to’s on this forum and elsewhere I finally managed to get this to work from this thread: https://www.ads-software.com/support/topic/php-else-if-for-child-pages

    Using the following code as given in the above mentioned thread.

    <?php if (is_page('about')) { ?>
    <!-- code here -->
    
    <?php } elseif (is_page('programs')) { ?>
    <!-- code here -->
    
    <?php } elseif (is_page('calendar')) { ?>
    <!-- code here -->
    
    <?php } else { ?>
    <!-- code here -->
    
    <?php } ?>
Viewing 1 replies (of 1 total)
  • The topic ‘If Else statement to control video tag per page’ is closed to new replies.