Move Post Title
-
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.
-
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.
Thanks – that worked!!
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? π
I’m using a child theme, but that code still isn’t workingin my child theme. Any other ideas?
Is this Snippet what you meant to do?
No, that’s just moving tags – I want the title gone.
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.
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); } }@electricfeet – where do I add the html in? In the php file, or just the post? Thanks for working on this!
It should go in the functions.php file of your child theme.
That worked – you’re awesome @electricfeet!
The topic ‘Move Post Title’ is closed to new replies.
