Wordpress homepage reveal after video finishes playing - php

I'm working on a Wordpress theme where when visiting the homepage, a short animated video is played, and once it has finished playing it 'fades' away a reveals a static page of text and the header. I'm not quite sure how to achieve this but I've provided my code below.
home.php
<?php
/*
* Template Name: Homepage
*/
get_header();
?>
<div id="primary" class="content-area offset-md-1 col-md-10">
<main id="primary" class="site-main home-page">
<div id="first">
<video src="http://localhost:8888/myvideo.mp4" controls autoplay></video>
</div>
<div id="second">
<div class="home-menu">
<?php
wp_nav_menu(
array(
'theme_location' => 'menu-1',
'menu_id' => 'primary-menu',
)
);
?>
<p>Lorem Ipsum</p>
</div>
</div>
</main><!-- .site-main -->
</div><!-- .content-area -->
<?php
get_sidebar();
get_footer();
style.css

The video should be on top of the content first, so you can position it the right way using CSS in the style.css of your theme:
#first {
width: 100%; /* full screen width */
height: 100vh; /* full screen height */
position: absolute; top: 0; left: 0;/* stay in place */
z-index: 1; /* sit on top */
opacity: 1; /* it is fully visible */
transition: 0.5s; /* time to move */
}
.leave {
opacity: 0; /* it is invisible */
width: 0; /* it has no width */
}
#first video {
width: 100%; height: 100vh; /* video fit container */
}
We added a leave class for the hidden state after the video is loaded. That is all for the CSS part. Let's now get back to your page template file. We will use javascript to add the leave-class to the video, after it ended playing.
In Javascript you can use the addEventListener() method:
addEventListener("ended", yourScript);
In your html, you give an ID name to the video element: <video id="myVid" src...
With this having set, you can use the method and run a function when the video ends. Put this after your closing content-area div in the page template:
<script>
document.getElementById('myVid').addEventListener("ended", yourScript);
function yourScript(e){
var div = document.getElementById("first"); /* div container */
div.classList.add("leave"); /* add class to div */
}
</script>
This way your video gets the css class when it ended. In the CSS we took away the opacity and the width with a transition of 0.5 seconds. You can adjust it the way to like, this is just pure javascript and CSS.
There are also jQuery functions like fadeOut(500) if you prefer to use that.

Related

Footer menu only shows up on home page

I added a menu to the footer of my site in functions/footer.php, and it shows up as desired on my home page, but it doesnt show up on any of the Post pages.
here is the website http://www.cultcitychi.com/
Below is my footer.php code
`?>
</div><!-- #content -->
<footer id="colophon" class="site-footer" role="contentinfo">
<div class="site-info">
<?php // footer menu
wp_nav_menu( array('container_class' => 'menu-footer',
'theme_location' => 'secondary' ) ); ?>
</div><!-- .site-info -->
</footer><!-- #colophon -->
`
You need to add this code at the bottom of your single.php file in order to display the footer on each post page:
<?php get_footer(); ?>
UPDATE:
I checked your website using the developer tools and the footer is present on the posts page but it's not appearing because of a flaw in your CSS. Please add the following CSS at the bottom of your stylesheet and that should solve the problem:
.single.single-thumbnail .site {
height: auto;
}
.single.single-thumbnail .site-footer {
padding-top: 0px;
}
.site-info {
margin: 0px auto;
padding-bottom: 0px;
}
footer#colophon {
z-index: 999;
}

Wordpress: trying to make a single static blank page that shows the header/sidebar/footer of my twenty fourteen template

I have made a static blank page that also shows my website's header/sidebar/footer in it. Now what i am trying to do is get rid of the 'style' that my wordpress template css is forcing me to have on the page i am trying to create.
Here is my code:
<?php
/*
* Template Name: My own page!
* Description: I made a page!
*/
require (dirname(dirname( __FILE__ )).'/wp-load.php');
get_header(); ?>
<div id="main-content" class="main-content">
<?php
if ( is_front_page() && twentyfourteen_has_featured_posts() ) {
// Include the featured content template.
get_template_part( 'featured-content' );
}
?>
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<!-- MY CONTENT!!! -->
Hello2.
<h1> hello.</h1>
<p>hello</p>
<input type="submit" name="connect" value="CONNECT" style="height:52px ; width:136px"/>
<p>hi</p>
<!-- -->
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar( 'content' ); ?>
</div><!-- #main-content -->
<?php
get_sidebar();
get_footer();
Any help appreciated.
You will need to overwrite the styles which are already in the theme. For example, you can give an id to your submit button like <input type="submit" name="connect" value="CONNECT" id="submitbutton"> and then style it according to your needs using CSS, for example:
input#submitbutton {
height: 52px;
width: 136px;
background: blue;
color: white;
}
Same goes for the <h1> tags. Give an <id> to your <h1> tag like <h1 id="hello"> hello.</h1> and then style it according to your needs using CSS, for example:
h1#hello {
color: black;
font-weight: bold;
font-size: 20px;
}
Use of Developer Tools over here will help you quite a lot in order to see how an element would look with your desired styles before actually making any changes to its CSS.
you will need to use something like
get_header('custom-header');
And use a custom header file to only load the stuff you want. You may need to create a custom function to override the scripts included by the theme...

Wordpress: On hover load title of post into a specific DIV

I'm currently working on a wordpress template where the title of a post is hidden and on hovering the post, it should be displayed on the bottom of the browser. To simplify, the post has this structure:
<article class="post">
<header class="article-header">
<h2 class="entry-title">
Post Title
</h2>
</header>
<section class="entry-content">
Post Content
</section>
</article>
Basically, I'd like to have a fixed in the body, that sits on the bottom of the browser and when a post is hovered, the content of its child element is passed into the . My approach so far was to have all elements constantly fixed to the browser bottom (hidden) and on a hover, each of them will be display. That led to a couple of problems and I thought I'd might be easier to have one empty div, which just grabs the title information.
Can anyone help me with that, maybe with jQuery or php?
Thanks!
you mean, something like this? http://jsfiddle.net/rKhqT/5/
HTML:
<article class="post">
<header class="article-header">
<h2 class="entry-title">
Post Title
</h2>
</header>
<section class="entry-content">
Post Content
</section>
</article>
<footer></footer>
CSS:
html, body {
margin: 0;
height: 100%;
}
.entry-title {
display: none;
}
footer {
position: fixed;
left: 0;
bottom:0;
width: 100%;
height: 30px;
border: 1px solid black;
}
JS (requires jQuery) :
$(document).ready(function() {
$('article.post').mouseover(function() {
$('footer').text($(this).find('h2').text());
});
$('article.post').mouseout(function() {
$('footer').text('');
});
});

Bootstrap fluid layout on wordpress issue

Hi Is there any of you out there that is able to assist me on this. I'm experimenting with the fluid layout of bootstrap on my wordpress site. Apparently the isn't working properly. I created a .span 12 column and its not taking up the full width of the browser. Instead its width shrank. Is there a way around this?
Heres the experiment which i created using a custom page template
<?php
/*
Template Name: page-work
*/
?>
<?php get_header(); ?>
<h1><?php the_title(); ?></h1>
<style type="text/css">
.span12{
background:black;
color:white;
padding:20px 0;
text-align:center;
margin-top:15px;
}
.span6{
background:blue;
color:white;
padding:20px 0;
text-align:center;
margin-top:15px;
}
</style>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">span 12</div>
</div>
<div class="row-fluid">
<div class="span6">span 6</div>
<div class="span6">span 6</div>
</div>
</div>
This is because bootstrap has a fixed width of span12 as
.span12 {
width: 1170px;
}
for bigger screens.
If you still want, you can try this:
#media (min-width: 1200px) {
.span12 {
width: 100%;
}
}
Always create a child css file and put that below the bootstrap file.
I would recommend upgrading to Bootstrap 3 as it handles fluid-containers in a much better way and you wouldn't have this problem in the first place.
.span12 becomes col-xx-12 (xx is either xs, sm, md and lg...read up on that!) and has a width of 100%. BS3 uses percentage widths rather than fixed widths as mentioned in the answer above. It's also not too difficult to move from BS2 to 3.
http://getbootstrap.com/ - download here
http://getbootstrap.com/getting-started/ - documentation
As a general rule, wordpress won't really change how your website looks. It's the styles you put around it so Wordpress in this case is irrelevant.

jquery rollovers not working in IE

Really struggling to understand this problem, any ideas are welcome
I have a carousel of images and all have rollovers that appear in every browser but IE, (testing in IE8 at the mo)
Live site
http://www.warface.co.uk/clients/warface.co.uk/testv2
click top red box to reveal
To add to the confusion rollover appears when an image isnt present
HTML
<div class="anyClass">
<ul><?php query_posts('category_name=project'); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li><div class="project-thumb caption">
<div class="cover boxcaption">
<div class="content">
<h2><?php the_title() ?></h2>
<a class="view-project" href="<?php the_permalink() ?>">View Project</a>
</div><!--content END -->
</div><!-- cover boxcaption END -->
</div><!-- project-thumb caption END -->
<?php $description = get_post_meta($post->ID, "project-thumb", $single = true);
if($description !== '') { echo $description; } ?></li>
<?php endwhile; endif;
wp_reset_query(); ?>
</ul></div><!-- anyClass END -->
CSS
.project-thumb { /* -- This is the hit area -- */
overflow: hidden;
width:499px;
height:337px;
display:block;
top:0px;
right:0px;
position: absolute;
}
.project-thumb .boxcaption { /* -- This is the sliding area -- */
background: #f7c923;
position: absolute;
width:499px;
opacity: .9; /* For IE 5-7 */
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=90); /* For IE 8 */
-MS-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=90)";
}
.caption .boxcaption {
height:100%;
left: 100%;
}
.project-thumb .content {
width:400px;
display:block;
margin:0 auto;
top:34%;
position: relative;
display:block;
}
** -- EDIT -- **
JS
$('.project-thumb.caption').hover(function(){
$(".cover", this).stop().animate({left:'0%'},{queue:false,duration:0}); //Position on rollover
},function() {
$(".cover", this).stop().animate({left:'100%'},{queue:false,duration:0}); //Position on rollout
});
The problem is that in IE you cannot hover over an empty div and have the mouseover event fire. You'll notice in developer tools that if you select the div element it just selects the image and completely bypasses the overlayed div.
There are two ways around this: you can set the "project-thumb" div to have a transparent background (using css3 or a transparent image) or give it a border. I was able to test this in your page in IE and it works just fine now. Look here for more info on being able to hover over an empty div in IE.

Categories