Archived topic
Code block appearing on pages other than Home page, when it shouldn't
3 replies · Started by Matthew on September 16, 2020
Hi. I'm using GP Premium 1.10 at this point, with 2.42 theme and WP 5.5.1.
I have the following code block in the "After Header" section of GP Hooks:
----
<?php if ( is_front_page() ) : ?>
<style>
.jumbotron {
color: inherit;
background-color: #aaa;
background-blend-mode: multiply;
background-repeat: no-repeat;
background-size: cover!important;
background-position: center 48%;
padding-bottom: 1.25rem;
position: relative;
text-align: center;
}
.jumbotron-overlay {
padding: 1rem 0;
position: relative;
z-index: 99;
}
.jumbotron h1 {
color: #fff;
font-size: 2rem;
letter-spacing: -1px;
margin: 0;
padding: 1rem 0;
text-shadow: 0 0 8px rgba(0,0,0,.325);
}
.jumbotron-container-content {
color: #fff;
margin: 0 auto;
padding: .5rem;
width: 100%;
}
@media (min-width: 470px) {
.jumbotron-container-content {
width: 84%;
}
}
.link-essays {
color: #fff !important;
padding-bottom: 2px;
border-bottom: 3px solid;
}
.link-essays:hover {
color: #e19251 !important;
}
#uFePSBlGCz .gridgum_header2, #uFePSBlGCz .gridgum_headline {
font-size: 1.125rem;
}
#uFePSBlGCz input {
display: block;
margin-bottom: .5rem;
margin-left: auto;
margin-right: auto;
}
@media (min-width: 550px) {
#uFePSBlGCz input {
display: inline-block;
}
}
#uFePSBlGCz .gridgum_note {
font-size: .75rem;
}
#uFePSBlGCz .mo-optin-error {
color: #f47149;
display: none;
}
#uFePSBlGCz .mo-optin-fields-wrapper {
margin-top: 1rem;
}
#uFePSBlGCz .mo-optin-form-headline {
padding: 1rem 0 .5rem 0;
}
</style>
<script type="text/javascript">
jQuery(function($) {
var images = ['jumbotron_00.jpg', 'jumbotron_01.jpg', 'jumbotron_02.jpg', 'jumbotron_03.jpg', 'jumbotron_04.jpg', 'jumbotron_05.jpg', 'jumbotron_06.jpg', 'jumbotron_07.jpg', 'jumbotron_08.jpg', 'jumbotron_09.jpg', 'jumbotron_10.jpg', 'jumbotron_11.jpg', 'jumbotron_12.jpg', 'jumbotron_13.jpg'];
$('.jumbotron').css({'background-image': 'url(wordpress/wp-content/uploads/2018/04/' + images[Math.floor(Math.random() * images.length)] + ')'});
});
</script>
<?php endif; ?>
----
So this was (as far as I know) only appearing and still should be appearing on only the home page, but it is now appearing on other (archive) pages on the site. The home page is https://publicresponse.com (where it should appear), but then it's on pages like https://publicresponse.com/page/2/ .
Any idea what the problem may be?
Thank you.
-Matt Kazmierski
Hi there,
use this for your template condition:
if ( is_front_page() && !is_paged() )
That worked. Thank you very much David.
Best,
Matt
You're welcome