Updated March 2015: This snippet now works only with Customizr > 3.3.1 and Customizr-Pro > 1.0.12
This little snippet gives a simple solution to display the post metas at the bottom of a single post in the Customizr theme, (instead of right below the post title).
This code has to be pasted in the functions.php of a child theme.
//we hook the code on the __before_body hook, which is executed before the <body> rendering. add_action ('__before_body' , 'move_single_post_metas'); function move_single_post_metas() { //checks if we are displaying a single post. Returns false if not. if ( ! is_single() ) return; //we remove the original action hooked on '__post_metas'. tc_post_metas action is a method of the TC_post_metas class //We can access the instance of this class with a static property of this class that is a self instance. remove_action ( '__after_content_title' , array( TC_post_metas::$instance , 'tc_set_post_metas_hooks' ), 20); //we add the tc_post_metas action on a the __after_loop (check index.php file to see where this hook is called in the code) add_action ('__after_article' , array( TC_post_metas::$instance , 'tc_set_post_metas_hooks'), 10); //Additional action to display an hr separator between content and metas. //We use the priority parameter to determine the rendering order of the action add_action ('__after_article' , 'display_hr', 0); //this is a nested function (function in another function), allowed with PHP. function display_hr() { ?> <hr/> <?php } }
24 thoughts on “Moving single post metas to the bottom of the post”
Hi,
You can probably disable categories and tags from post metas display.
Also, hook into __after_article to display categories and tags to the bottom of the post.
Please post at the support forum if you have any issues with this.
How can i move the categories and tags to the bottom of the Post? Date and author should remain under the headline.
What if I only want to move the TAGS to the bottom but not the author and category and date?
Hi, this is great, thank you. But I would like to do a little bit more in the same direction. Could you please help me?
I would like to move all of the stuff that comes before the content on single posts below it. The breadcrumbs, the title, the metas and the sharing buttons. Or the other way around, I would like to move the post content ahead of these, right below the header.
I found the other instructions about how to add a block of content below the header but I’m not sure how I would have to reference the post content inside this code.
Now I’ve tried to understand what’s wrong but I don’t get it. It looks ok except for the blog list where the metas shows up below the second separator.
When I deleted:
//Additional action to display an hr separator between content and metas.
//We use the priority parameter to determine the rendering order of the action
add_action (‘__after_article’ , ‘display_hr’, 0);
One of the separators disappeared and it looks a bit better. But it would of course great if I could be able to move the metas above the separator.
Gaah, sorry for being such an amateur! 😉
Hi Mats,
You’ll want to use the collowing code to achieve what you need :
I hope this will help 🙂
Nicolas.
Hello Nicolas,
I just inserted this code into my functions.php on a child theme, and it completely wiped my website clean.
I am no receiving this message:
“Fatal error: Cannot redeclare move_single_post_metas() (previously declared in /home/content/p3pnexwpnas09_data01/14/2484714/html/wp-content/themes/milk-wasted-mama_2/functions.php:9) in /home/content/p3pnexwpnas09_data01/14/2484714/html/wp-content/themes/milk-wasted-mama_2/functions.php on line 33”
I cannot even access my wordpress dashboard!! PLEASE HELP!!!!
Nevermind, after a ton of research and trial and error, I figured it out! PHEW!!
Grea, thanks for the update! 🙂
What was the problem ?
Hi
I have two questions about the meta information:
1. I’d like to move the metas to the bottom of the posts, both in the blog list and on the single posts.
The single posts works fine with the code provided at the top of this page, but when I follow Nicolas instructions above, to delete
if ( !is_single() )
return;
it seems like something’s missing.
The metas shows up just above the header of the next post (in the list) instead of between the two separators at the end of the post.
2. Is it possible to keep the publish date as it looks now and move the rest of the metas to the end of the post?
I don’t know anything about the codes, I just copy & paste….;)
Hi Mats,
1) it might be a question of hook priority.
2) Yes it is possible of course but would require some coding.
If you are new to the theme and WordPress coding in general, I would recommend to read this documentation on how to customize the theme and read other snippets to have a better understanding of what’s behind the concepts… 🙂 don’t worry, it’s not that hard!
Cheers
I used this snippet and it works fine on a single post page. A related question is, how to remove or move the meta information to the bottom of the excerpt that is listed when you visit the “blog” page, i.e. the list of posts? It clutters up the page.
Thanks for any hints.
Best regards, Magnus
Hello,
I have been looking for this also. The single post is not that much of an issue for me as there is so much stuff on single post anyhow that the meta does not affect its look that much. For excerpt it is different though when meta can suddenly take almost as much space as the text in excerpt itself. I would like to remove meta from the excerpt part if at all possible.
Hi Marcus and Markoh,
It’s all about setting the right condition at the beginning of the function.
In the provided snippet, I have used the ! is_single() conditional statement.
If you get rid of it, the metas will be moved at the bottom of the post in every WordPress context : post, page, list of posts, search results, category, tags, date archives, …
You can target more specifically the blog page with the is_posts_page property of the global $wp_query object generated by WordPress.
This code means : if this is NOT the blog posts page, then return nothing (break the function if you will).
Hope this helps!
Hi Kate you are not a “problem” ! 🙂
Did you make sure you pasted the code in the right place? More about customizing Customizr here : http://www.presscustomizr.com/customizr/how-to-customize-customizr-wordpress-theme/
Yes, I am 99.9% sure that I put the code in the correct place. There is a child theme for Customizr, and I placed the code in the functions.php in the child theme. I put it first at the bottom, after some other stuff that the client already had in there. When that didn’t work, I moved it to the top of the file, just after
It doesn’t seem to make any difference no matter where in the child theme functions file I place it.
Hi Kate, would you mind to open a new topic here with a link to your website?
I’m sorry to be a problem, but the new code still isn’t working … I replaced the old code, uploaded the functions.php, and the tags are still at the top under the post title.
Same as Allison … I added the code to the child functions file, refreshed the page, and no change.
Hi @Kate and @Allison, after verification I realized that there was a problem in the code.
The hook to add the new actions has to be ‘__after_article’, instead of ‘__after_loop’.
This is now fixed in the code snippet.
Thanks for the feedback, this will help many people!
Best regards and enjoy the theme.
Hello.
I selected the code above, copied it, and pasted it into the functions.php box in my child theme customizer. I saved it and refreshed my website, and nothing happened. The tags still appear at the top of the post, just below the title.
Did I miss a step?
Thank you
Hi Allison, what you did is right, this whould work fine.
The above snippet wasnt working for me. More specifically, it was not removing orginal meta after the tile.
I modified the line
remove_action ( ‘__post_metas’ , array( TC_post_metas::$instance , ‘tc_post_metas’ ));
to
remove_action ( ‘__after_content_title’ , array( TC_post_metas::$instance , ‘tc_post_metas’ ));
Hey thanks for this feedback Ankur! You are absolutely right, I just updated the snippet with the correct hook ‘__after_content_title’.
Your contribution is much appreciated, cheers.