Skip to content
Back Home
  • Customizr Pro
  • Hueman Pro
  • Nimble Page Builder
  • Blog
  • Search
Back Home
  • Customizr Pro
  • Hueman Pro
  • Nimble Page Builder
  • Blog
Home » Snippets » WordPress functions » is_single() » Moving single post metas to the bottom of the post
code snippets html php Post metas Posts __after_content_title __after_loop __before_body __post_metas is_single() remove_action()

Moving single post metas to the bottom of the post

by Nicolas|Published 22 October 2013

⚠️ Code snippets might not be compatible with the latest version of your theme. Always use a child theme to customize your theme, and test your code on a staging website before migrating to production.

You can search the user’s forum or ask the user community by opening a new thread in the Customizr theme forum. Before opening a new topic, you might want to follow the troubleshooting steps..

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
  }
}

 

AUTHOR

Nicolas
Hi! I'm Nicolas (@presscustomizr), the lead developer of the Customizr Theme and the Hueman Theme. My team and I are working everyday to help you publish your WordPress content the best possible way. We love to do it!Thanks for visiting this website, feel free to drop us a line !
0 posts

You may also like

Change font size of specific words in Slider title
Published 26 February 2016

Change font size of specific words in Slider title

The slider of the Customizr theme is used to attract attention to certain important posts. What if you want to give emphasis […]

Enter text above posts on a static blog page
Published 8 July 2014

Enter text above posts on a static blog page

If you’ve set up the Customizr theme so that you have you blog posts on a separate page, here’s how to include some text or other content above the posts.

Featuring pages on another page / post than home
Published 6 August 2014

Featuring pages on another page / post than home

Let’s say you’ve setup three beautiful featured pages on your home page. Now you might want to display this block of featured pages in another […]

Remove Post Meta Details
Published 27 September 2013

Remove Post Meta Details

Customizr introduced built-in feature changes in v3.3. For more details, read the Documentation This Snippet is preserved for Users of 3.1/3.2 If […]

Impress your visitors with a perfect experience on smartphones

customizr-pro-screenshot

10K+ small businesses are already using the Customizr Pro WordPress theme for their online presence.

Discover Customizr Pro

Post navigation

  • Previous post Add a border underneath the Slider
  • Back to post list
  • Next post Remove Navbar Box
Useful pages
  • Your account
  • Product Support
  • Documentation
  • WP code snippets for Customizr theme
  • Work with us
Company
  • About
  • Blog
  • Privacy Policy
  • Terms of sale
  • Contact Us
Products and Services
  • Customizr Pro
  • Hueman Pro
  • Customizr WordPress Theme
  • Hueman WordPress Theme
  • Nimble Builder

© 2021 Press Customizr – All rights reserved