Difficulty Removing footer markup conditionally

Community Forums Forums Design Tips and Tricks Difficulty Removing footer markup conditionally

This topic is: resolved

This topic contains 12 replies, has 2 voices, and was last updated by  braddalton 11 months, 3 weeks ago.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #53315

    Alessandra
    Participant
    Post count: 30

    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.

    #53319

    braddalton
    Participant
    Post count: 8835

    Use this code but change the conditional tag and the remove actions to suit your needs.

    https://gist.github.com/braddalton/5305974


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #53322

    Alessandra
    Participant
    Post count: 30

    Hello, 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?

    • This reply was modified 11 months, 4 weeks ago by  Alessandra.
    • This reply was modified 11 months, 4 weeks ago by  Alessandra.
    #53329

    braddalton
    Participant
    Post count: 8835

    Hi 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.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #53331

    braddalton
    Participant
    Post count: 8835

    Please 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++


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #53399

    Alessandra
    Participant
    Post count: 30

    The 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.

    • This reply was modified 11 months, 4 weeks ago by  Alessandra.
    • This reply was modified 11 months, 4 weeks ago by  Alessandra.
    #53477

    braddalton
    Participant
    Post count: 8835

    As 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:
    [php]
    if ( is_single() || is_page( ) ) {
    [/php]

    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/


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #53483

    braddalton
    Participant
    Post count: 8835

    Can you please link to your site Charles so i can check a few things. Thanks.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #53487

    Alessandra
    Participant
    Post count: 30

    I 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!

    #53493

    Alessandra
    Participant
    Post count: 30

    Brad, 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.

    • This reply was modified 11 months, 3 weeks ago by  Alessandra.
    • This reply was modified 11 months, 3 weeks ago by  Alessandra.
    #53500

    braddalton
    Participant
    Post count: 8835

    Your code is missing the function and hook
    [php]
    add_action( ‘genesis_before’, ‘wpsites_remove_footer_markup’ );
    [/php]

    Try this:

    [php]
    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 );
    }}
    [/php]


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #53669

    Alessandra
    Participant
    Post count: 30

    Thanks 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! =)

    #53671

    braddalton
    Participant
    Post count: 8835

    Best way to learn Charles.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.