WordPress.org

Ready to get started?Download WordPress

Forums

Customizr
[resolved] Move Post Title (12 posts)

  1. satrntgr
    Member
    Posted 9 months ago #

    I was able to change the html to move the tags to the bottom of my post, but how do I move the post title to the bottom as well? I can't find the info anywhere. Thanks.

  2. tomaja
    Member
    Posted 9 months ago #

    Hi @satrntgr,
    for moving post header to the bottom of the post you can use this code, just add it to your function.php in child theme:

    add_action ('__before_body' , 'move_post_header');
    
    function move_post_header() {
    
            remove_action  ( '__before_content' , array( TC_post::$instance , 'tc_post_header' ));
            add_action  ( '__after_content' , array( TC_post::$instance , 'tc_post_header' ), 1);
    }

    This works for full posts. Hope it helps.

  3. satrntgr
    Member
    Posted 9 months ago #

    Thanks - that worked!!

  4. satrntgr
    Member
    Posted 7 months ago #

    Sorry, they just did another update and I cannot figure out how to use the child theme. I added the html to the functions file, but it didn't work. Now what? :(

  5. satrntgr
    Member
    Posted 7 months ago #

    I'm using a child theme, but that code still isn't workingin my child theme. Any other ideas?

  6. rdellconsulting
    Member
    Posted 7 months ago #

    Is this Snippet what you meant to do?

  7. satrntgr
    Member
    Posted 7 months ago #

    No, that's just moving tags - I want the title gone.

  8. ElectricFeet
    Member
    Posted 7 months ago #

    What seems to have happened is that @nikeo has split off the rendering of the headings to class-content-headings.php. I presume to reduce repetition. So the code in functions.php now becomes:

    //we hook the code on the wp_head hook, this way it will be executed before any html rendering.
    add_action ( 'wp_head' , 'move_my_post_headers');
    function move_my_post_headers() {
        //we unhook the header
        remove_action( '__before_content' , array( TC_headings::$instance , 'tc_content_headings' ));
    
        //we re-hook the header. Check the priority here : set to 0 to be the first in the list of different actions hooked to this hook
        add_action( '__after_content' , array( TC_headings::$instance , 'tc_content_headings' ), 0);
    }

    The unfortunate side-effect of consolidating the header code, however, is that if you apply the code above, all the content headings — of pages, posts, and post-lists — will be at the bottom, not just on the posts. This may or may not be what you wanted.

  9. ElectricFeet
    Member
    Posted 7 months ago #

    OK. I've now worked this out. You can add a test to check you are on a single post. The code that only moves the title when viewing a individual post is as follows:

    //we hook the code on the wp_head hook, this way it will be executed before any html rendering.
    add_action ( 'wp_head' , 'move_my_post_headers');
    function move_my_post_headers() {
    	// check if we're on a single post; if not, do nothing
    	global $post;
        if ( isset($post) && 'page' != $post -> post_type && 'attachment' != $post -> post_type && is_singular() ) {
    
    	    //we unhook the header
    	    remove_action( '__before_content' , array( TC_headings::$instance , 'tc_content_headings' ));
    
    	    //we re-hook the slider. Check the priority here : set to 0 to be the first in the list of different actions hooked to this hook
    	    add_action( '__after_content' , array( TC_headings::$instance , 'tc_content_headings' ), 0);
    	}
    }
  10. satrntgr
    Member
    Posted 7 months ago #

    @ElectricFeet - where do I add the html in? In the php file, or just the post? Thanks for working on this!

  11. ElectricFeet
    Member
    Posted 7 months ago #

    It should go in the functions.php file of your child theme.

  12. satrntgr
    Member
    Posted 7 months ago #

    That worked - you're awesome @ElectricFeet!

Reply

You must log in to post.

About this Theme

About this Topic