Post Title Function to Entry Content from Entry Header
-
efflerekParticipant
Hello,
I would like to move post title and postmeta to entry content.
I don’t wanna have them in entry header.Can You help me?
How to do it?Daniel TaraKeymasterThe post title and meta were not designed to be hooked there. It is possible but you will need to apply some custom code.
First you need to create a child theme.
In the child theme’s functions.php file add the following code:
function enlightenment_child_the_title() { $args = enlightenment_the_title_args(); the_title( $args['before'], $args['after'] ); } function enlightenment_child_remove_entry_hooks() { remove_action( 'enlightenment_entry_header', 'the_title', 10, 2 ); if( ! is_page() ) { remove_action( 'enlightenment_entry_header', 'enlightenment_entry_meta' ); } } add_action( 'wp', 'enlightenment_child_remove_entry_hooks', 9 ); function enlightenment_child_add_entry_hooks() { add_action( 'enlightenment_entry_content', 'enlightenment_child_the_title' ); if( ! is_page() ) { add_action( 'enlightenment_entry_content', 'enlightenment_entry_meta' ); } } add_action( 'wp', 'enlightenment_child_add_entry_hooks', 8 ); function enlightenment_child_remove_teaser_entry_hooks() { if( ! current_theme_supports( 'enlightenment-grid-loop' ) || ! enlightenment_is_lead_post() ) { return; } remove_action( 'enlightenment_entry_header', 'the_title', 10, 2 ); } add_action( 'enlightenment_before_entry', 'enlightenment_child_remove_teaser_entry_hooks', 6 ); function enlightenment_child_add_teaser_entry_hooks() { if( ! current_theme_supports( 'enlightenment-grid-loop' ) || ! enlightenment_is_lead_post() ) { return; } add_action( 'enlightenment_entry_content', 'enlightenment_child_the_title' ); } add_action( 'enlightenment_before_entry', 'enlightenment_child_add_teaser_entry_hooks', 5 ); function enlightenment_child_entry_hooks( $hooks ) { $hooks['enlightenment_entry_content']['functions'][] = 'enlightenment_child_the_title'; return $hooks; } add_filter( 'enlightenment_entry_hooks', 'enlightenment_child_entry_hooks', 6 ); function enlightenment_child_template_functions( $functions ) { $functions['enlightenment_child_the_title'] = __( 'Post Title', 'enlightenment' ); return $functions; } add_filter( 'enlightenment_template_functions', 'enlightenment_child_template_functions', 6 );
Now upload the child theme and activate it. The post title and meta should have moved to the entry content area. If you made any modifications using the template editor you may need to move them manually from there.
efflerekParticipantThanks for very fast answer and help.
When I try to activate my theme it shows this communicate:
Fatal error: Cannot use [] for reading in /wp-content/themes/enlightenment-child/functions.php on line 54
Now, my functions.php looks like that. I bolded 54′ line.
<?php
// Exit if accessed directly
if ( !defined( ‘ABSPATH’ ) ) exit;// BEGIN ENQUEUE PARENT ACTION
// AUTO GENERATED – Do not modify or remove comment markers above or below:if ( !function_exists( ‘child_theme_configurator_css’ ) ):
function child_theme_configurator_css() {
wp_enqueue_style( ‘chld_thm_cfg_child’, trailingslashit( get_stylesheet_directory_uri() ) . ‘style.css’, array( ‘enlightenment-theme-stylesheet’ ) );
}
function enlightenment_child_the_title() {
$args = enlightenment_the_title_args();
the_title( $args[‘before’], $args[‘after’] );
}function enlightenment_child_remove_entry_hooks() {
remove_action( ‘enlightenment_entry_header’, ‘the_title’, 10, 2 );if( ! is_page() ) {
remove_action( ‘enlightenment_entry_header’, ‘enlightenment_entry_meta’ );
}
}
add_action( ‘wp’, ‘enlightenment_child_remove_entry_hooks’, 9 );function enlightenment_child_add_entry_hooks() {
add_action( ‘enlightenment_entry_content’, ‘enlightenment_child_the_title’ );if( ! is_page() ) {
add_action( ‘enlightenment_entry_content’, ‘enlightenment_entry_meta’ );
}
}
add_action( ‘wp’, ‘enlightenment_child_add_entry_hooks’, 8 );function enlightenment_child_remove_teaser_entry_hooks() {
if( ! current_theme_supports( ‘enlightenment-grid-loop’ ) || ! enlightenment_is_lead_post() ) {
return;
}remove_action( ‘enlightenment_entry_header’, ‘the_title’, 10, 2 );
}
add_action( ‘enlightenment_before_entry’, ‘enlightenment_child_remove_teaser_entry_hooks’, 6 );function enlightenment_child_add_teaser_entry_hooks() {
if( ! current_theme_supports( ‘enlightenment-grid-loop’ ) || ! enlightenment_is_lead_post() ) {
return;
}add_action( ‘enlightenment_entry_content’, ‘enlightenment_child_the_title’ );
}
add_action( ‘enlightenment_before_entry’, ‘enlightenment_child_add_teaser_entry_hooks’, 5 );function enlightenment_child_entry_hooks( $hooks ) {
$hooks[‘enlightenment_entry_content’][‘functions’][] ‘enlightenment_child_the_title’;
return $hooks;
}
add_filter( ‘enlightenment_entry_hooks’, ‘enlightenment_child_entry_hooks’, 6 );function enlightenment_child_template_functions( $functions ) {
$functions[‘enlightenment_child_the_title’] = __( ‘Post Title’, ‘enlightenment’ );
return $functions;
}
add_filter( ‘enlightenment_template_functions’, ‘enlightenment_child_template_functions’, 6 );
endif;
add_action( ‘wp_enqueue_scripts’, ‘child_theme_configurator_css’ );Daniel TaraKeymasterThe line is missing an
=
sign. Should be:$hooks['enlightenment_entry_content']['functions'][] = 'enlightenment_child_the_title';
Tagged: Entry Content, entry header, post meta, post title, theme options
You must be logged in to reply to this topic.