Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

Changing Body attributes via custom Page template

$
0
0

Replies: 0

I am adapting an older site to WordPress. The site included HTML pages which played video at full width, with no other control options.

Within another theme (Divi), I created a Page template (based on a default Blank Page template) and removed the header, sidebar, footer, and title. The Page now works well (so I only insert an iframe link for the video within the text editor).

However, the Page still includes the basic browser padding/margin/whatever around the video — it’s not 100% width, because of the normal body padding around all(?) web pages.

Also, on these pages, I also need to change the bgcolor, and some other functions, as shown in the original HTML:

<head>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
	<title>Whatever</title>
<style>
.not-active {
  pointer-events: none;
  cursor: default;
  text-decoration:none;
  color:black;
}
</style>
</head>
<body bottommargin="0" leftmargin="0" marginheight="0" marginwidth="0" rightmargin="0" topmargin="0" bgcolor="black">
<iframe class="not-active" width="100%" height="100%" src="https://www.youtube.com/watch?v=dQw4w9WgXcQ" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</body>		 
</html>

(Sample video link above.) How could I best make those changes within the Custom Page template?

I’ve been at this for days, and getting nowhere.

I tried using directions found here:

https://code.tutsplus.com/tutorials/adding-to-the-body-class-in-wordpress–cms-21077

This is what I added to the Custom CSS area:

body.video-page {
  margin: 0px !important;
  background-color: black !important;
  pointer-events: none !important;
  cursor: default !important;
  text-decoration:none !important;
}

And this is what I added to the child theme’s functions.php:

add_filter( 'body_class','video_page_body_class' );
function video_page_body_class( $classes ) {
 
    if ( is_page_template( 'page-video.php' ) ) {
        $classes[] = 'video-page';
    }
    return $classes;

However, it didn’t work. Do you see any errors or how I might better approach this?

  • This topic was modified 15 minutes ago by websta.

Viewing all articles
Browse latest Browse all 59525

Trending Articles