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

Displaying the post metas on home page
Published 18 January 2014

Displaying the post metas on home page

If your home page displays your last WordPress posts, you may have noticed that the posts on home don”t show the metas […]

Check if we are currently using the WordPress customizer
Published 10 December 2013

Check if we are currently using the WordPress customizer

Howdy developer! Sometimes it might be the case that you need to execute actions only if the user is in the customization […]

Make the Footer ‘Sticky‘
Published 16 April 2014

Make the Footer ‘Sticky‘

Notice:: Since Customizr 3.4.6 and Customizr-Pro 1.2.0 a new option has been added to make the footer sticky. Navigate through Appearance -> […]

Change Sidebar borders
Published 20 October 2013

Change Sidebar borders

Where to copy/paste this code? The simplest way is to use the Custom CSS section of the customizer option screen. If you […]

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