Archived topic
How can I make the html in my 'before footer' section appear on selected pages?
10 replies · Started by kyle on December 9, 2016
Hello, I'm using the GP hooks addon and I've entered this html into it:
</h3>
And it's working as it should but I would like this to appear on one certain page only. How can I achieve this?
Hi Kyle
This should help https://generatepress.com/forums/topic/page-specific-hooks/#post-3719
Hello and thanks for that, it's half solved my problem, I can now select specific pages yes but for some reason now my content is not full screen as it was before and is in some sort of a container.
I'm a bit out of my depth here when it comes to php so I hope you or someone else can shed some light on the situation?
Thanks in advance :)
Hi Kyle,
Here's another way that doesn't involve PHP :) But it does require the very handy Simple CSS plugin, also from Tom here at GeneratePress. One of the main benefits of this plugin is that it provides a meta box in the page/post editor where you can enter CSS that will be specific for that page or post.
https://wordpress.org/plugins/simple-css/
To accomplish what you want, simply add a div on your HTML in the GP Hook location and give it an ID, e.g.
<div id="my-html"><h3>Now you know what swing trading is and what it isn’t, it’s time to learn the basics of swing trading.
</h3></div>
Then, in the Simple CSS editor, enter this to turn it OFF on ALL pages:
#my-html {
display: none;
}
Then, on the page you DO want it to display on, enter this in the Simple CSS meta box on that page:
#my-html {
display: inline;
}
Cheers!
Lyle
If your content container is acting different, you might have some broken HTML somewhere.
Make sure for every opening element (<div>, <p>, <span> etc..) there's a closing element (</div>, </p>, </span>).
I Still can't quite seem to get it.
<?php if ( is_page( 'page-id-47' ) ) : ?>
<div class="nextstep">
<h3>Now you know what swing trading is and what it isn't, it's time to learn the <a href="http://swingtradesmart.com/learn-to-trade/basics-of-swing-trading/">basics of swing trading.</a></h3>
</div>
<?php endif; ?>
This is the code I have on the before footer section in gp hooks and I have execute php checked and nothing show up on the page what so ever now.
any help would be most appreciated.
This assumes the page slug is yoursite.com/page-id-47: is_page( 'page-id-47' )
Instead, you can use this to target the ID: is_page( 47 )
<?php if ( is_page( 47 ) : ?>
<?php endif; ?>
This is the new code and still nothing. If I remove anything to do with PHP for example:
Then it works how I want it, but it just displays on every page. I'm still unsure as to what I'm doing wrong
You're missing a bracket there.
It should be:
<?php if ( is_page( 47 ) ) : ?>
<div class="nextstep">
<h3>Now you know what swing trading is and what it isn't, it's time to learn the <a href="http://swingtradesmart.com/learn-to-trade/basics-of-swing-trading/">basics of swing trading.</a></h3>
</div>
<?php endif; ?>
Thank you, that's got it :)
You're welcome :)