Community Forums › Forums › Archived Forums › Design Tips and Tricks › Difficulty Removing footer markup conditionally
Tagged: conditional, footer, markup
- This topic has 12 replies, 2 voices, and was last updated 11 years, 5 months ago by Brad Dalton.
-
AuthorPosts
-
July 30, 2013 at 8:10 pm #53315AlessandraMember
Hi!
Would someone please help me out on this:
I want the filter bellow to work only on posts and pages:
//* Remove the entry footer markup (requires HTML5 theme support) remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 ); remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );
Tried to do with:
if(is_single() || is_page()) { remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 ); remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 ); }
But had no success at all... It continues to output the markup and only works if i use without that conditional.
I'm not an php guy... =/
Any help will be more than appreciated.
Best regards.
July 30, 2013 at 11:07 pm #53319Brad DaltonParticipantUse this code but change the conditional tag and the remove actions to suit your needs.
https://gist.github.com/braddalton/5305974
July 30, 2013 at 11:34 pm #53322AlessandraMemberHello, Brad.
Tried your code but unfortunately i got no results...
I guess it is a pre html5 code, no?
I used some variations too, but also could not managed it to work as expected.
Used the "stock" version also, and it seems to do nothing, on my home page the footer markup keep showing normally with the unchanged code you suggested.
I can get away with the footer markup with:
//* Remove the entry footer markup (requires HTML5 theme support) remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 ); remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );
But then it removes the open and close tags globally, when i just want t remove them on single posts and pages.
Any more suggestions please?
July 31, 2013 at 12:54 am #53329Brad DaltonParticipantHi Charles
I tested that code which i always do before publishing it and it works perfectly.
Please note that the footer and footer widgets are different.
If you want to remove both and the markup, please use this code and change the conditional tags
The hooks outside the loop have not changed.
July 31, 2013 at 1:10 am #53331Brad DaltonParticipantPlease copy the code from the view raw link and paste it at the end of your child themes functions.php file using a text editor like Notepad++
July 31, 2013 at 9:41 am #53399AlessandraMemberThe footer i mean is this:
<footer class="entry-footer"></footer>
And as i said before, this is the code that is said to get rid of these markups:
//* Remove the entry footer markup (requires HTML5 theme support) remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 ); remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );
Using the above piece of code inside my functions removes this tags as i want. But it removes site-wide.
I would like to have a way to remove them only on single posts and pages, cause i am already putting them with another hook on them.
I saved the code you provided inside my functions.php but it dont remove the markup i am referring here. It is still there with this code and i think it relates to another different thing and we are not talking about the same thing.
The action that filters the footer i meant is genesis_entry_footer_markup_open ..._close
Any other help on how to use it as i need, working only on single posts and pages?
Best regards.
July 31, 2013 at 8:17 pm #53477Brad DaltonParticipantAs mentioned previously Charles, please change the conditional tag to suit your needs.
The code i provided is tested and works.
It removes the footer markup conditionally as well as the footer widgets.
The conditional tags for pages and posts are:
if ( is_single() || is_page( ) ) {
This code will remove the footer and markup conditionally:
The code you're referring to applies to the new HTML 5 loop hooks.
http://www.briangardner.com/code/remove-entry-footer-markup/
The genesis_entry_footer replaces the old XHTML genesis_after_post_content hook.
Learn more about the hook changes http://www.briangardner.com/code/genesis-html5-loop-hooks/
July 31, 2013 at 8:36 pm #53483Brad DaltonParticipantCan you please link to your site Charles so i can check a few things. Thanks.
July 31, 2013 at 9:14 pm #53487AlessandraMemberI will try your code again right now, Brad.
But the last time i used it as it is, and i can see it is setting the conditional to the home page, but checking my source code with the code inside my function.php i still had the markup on each post excerpt inside my home page and in itself.
I am using the html5 support, should it work with it or maybe your code is not compatible with it?
Maybe its me doing some foolish thing.
Unfortunately theres no link, because i'm doing it on my localhost, inside my computer.
I appreciate you help so much.
Will repport here what i get from this.
Thanks a lot!
July 31, 2013 at 9:55 pm #53493AlessandraMemberBrad, as i said before: we are talking about different footers.
The footer your code removes is this one:
<footer class="site-footer" role="contentinfo" itemscope="itemscope" itemtype="http://schema.org/WPFooter"><div class="wrap"><p>Footer Content Goes Here Baby</p></div></footer></div>
Its the last footer of the page.
The footer i am referring to is the footer that comes right after the
<div class="entry-content" itempro="tet">...</div>
Its the footer of the post / page content, not the footer of the page.As i said, its this footer right here the one i want to remove the open and close tags only on single posts and pages.
<footer class="entry-footer">...</footer>
Your code works, but the one that controls the markup i want to get rid is this one:
//* Remove the entry footer markup (requires HTML5 theme support) remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 ); remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );
If i use it as default, it removes the markup on single posts and pages, but also on my home page, categories and so on...
I tried to adapt the code to this:
function remove_only_single_page() { if ( is_single() || is_page( ) ) { remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 ); remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 ); }}
But it continues to output the footer markup in this case and only works with the default version... =/
What i need is a way to make it work only on posts and pages.
Maybe now you got my point.
Could you or someone else please give me some help on how to adapt this code to work as i need it to?
Thank you.
July 31, 2013 at 11:05 pm #53500Brad DaltonParticipantYour code is missing the function and hook
add_action( 'genesis_before', 'wpsites_remove_footer_markup' );
Try this:
add_action( 'genesis_before', 'wpsites_remove_footer_markup' ); function wpsites_remove_footer_markup() { if ( is_single() || is_page( ) ) { remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 ); remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 ); }}
August 1, 2013 at 9:00 pm #53669AlessandraMemberThanks a lot, Brad!
It worked!
I'm a self taught on all this stuff and all i can do is through trial and error...
I was not sure if the add_action( 'genesis_before', 'function_name_here' ); should be include in my case, thats why i had not used it before.
But now it seems to be working just as i wished.
And your help was vital to this.
So thanks again, man! =)
August 1, 2013 at 9:02 pm #53671Brad DaltonParticipant -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.