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

Moving Header Block items (3.3)
Published 21 April 2015

Moving Header Block items (3.3)

If you need to move Header Block Items, 3.3.* release created more options for doing this in the Customize>Header panel. This Snippet […]

Change the font/size/color of the Slider Titles
Published 20 October 2013

Change the font/size/color of the Slider Titles

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

Make the Header ‘Sticky’
Published 7 October 2013

Make the Header ‘Sticky’

Customizr introduced built-in feature changes in v3.2. Go to Customize>Header>Design and layout. Adjust the STICKY HEADER SETTINGS. 3.1/3.2 code Where to copy/paste […]

Change 3-bar menu to Inline on responsive viewports
Published 28 August 2015

Change 3-bar menu to Inline on responsive viewports

There is a lot of debate on the value of the 3-bar Hamburger Menu on the web. A fairly common request is […]

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