astra_single_get_post_meta()<\/em> where you want the post meta to appear.<\/li><\/ol>\n\n\n\nLet's go through those steps in detail.<\/p>\n\n\n\n
Some of the code isn't formatted the way I would normally do it. I've tried to keep it as close to the original Astra code as possible.<\/p>\n\n\n\n
Add a function laying out the new headline section<\/h2>\n\n\n\n Astra combines the headline and the post meta into a single function. To change that, you need to create your own version, using the same function name as they have. Because it's in a child theme, and because Astra is well programmed, your function will override the one in the parent theme.<\/p>\n\n\n\n
The original code (I removed extra lines for readability) is:<\/p>\n\n\n\n
function astra_get_single_post_title_meta() {\n \/\/ Single Post Title and Single Post Meta.\n do_action( 'astra_single_post_order_before' );\n ?>\n <div class=\"ast-single-post-order\">\n <?php\n do_action( 'astra_single_post_title_before' );\n astra_the_title( '<h1 class=\"entry-title\" itemprop=\"headline\">', '<\/h1>' );\n do_action( 'astra_single_post_title_after' );\n do_action( 'astra_single_post_meta_before' );\n astra_single_get_post_meta();\n do_action( 'astra_single_post_meta_after' );\n ?>\n <\/div>\n <?php\n do_action( 'astra_single_post_order_after' );\n}<\/code><\/pre>\n\n\n\nRemove these three lines:<\/p>\n\n\n\n
do_action( 'astra_single_post_meta_before' );\nastra_single_get_post_meta();\ndo_action( 'astra_single_post_meta_after' );<\/code><\/pre>\n\n\n\nYour function will be:<\/p>\n\n\n\n
function astra_get_single_post_title_meta() {\n \/\/ Single Post Title and Single Post Meta.\n do_action( 'astra_single_post_order_before' );\n ?>\n <div class=\"ast-single-post-order\">\n <?php\n do_action( 'astra_single_post_title_before' );\n astra_the_title( '<h1 class=\"entry-title\" itemprop=\"headline\">', '<\/h1>' );\n do_action( 'astra_single_post_title_after' );\n ?>\n <\/div>\n <?php\n do_action( 'astra_single_post_order_after' );\n}<\/code><\/pre>\n\n\n\nPut this into the functions.php<\/em> file of your child theme.<\/p>\n\n\n\nIn the final step, we'll put these three lines where we want the post meta to appear.<\/p>\n\n\n\n
Copy single-layout.php from the parent theme to your child theme<\/h2>\n\n\n\n The next step is to take the single-layout.php<\/em> file from the parent theme and put it into your child theme, keeping the same folder structure.<\/p>\n\n\n\nIn Astra, the file we want is under wp-content\/themes\/astra\/template-parts\/single\/single-layout.php<\/em>.<\/p>\n\n\n\nCopy that file to wp-content\/themes\/[child-theme]\/template-parts\/single\/single-layout.php<\/em>. Make sure you replace [child-theme]<\/em> with the folder name of your child theme.<\/p>\n\n\n\nFor example, my child theme is intelliwolf-astra-child<\/em> (obvious is good), so I would copy the file to wp-content\/themes\/intelliwolf-astra-child\/template-parts\/single\/single-layout.php<\/em>.<\/p>\n\n\n\nYou will probably need to create new folders in the child theme to get that file structure. It's a good idea to put blank files called index.php<\/em> into both of those new folders, to stop anyone snooping.<\/p>\n\n\n\nEdit the child theme's single-layout.php<\/h2>\n\n\n\n The last step is to add the astra_single_get_post_meta()<\/em> call in the single-layout.php<\/em> file of your child theme.<\/p>\n\n\n\nIt's a good idea to add the before and after hooks as well. The ones we removed from the function earlier.<\/p>\n\n\n\n
The lines we're adding are:<\/p>\n\n\n\n
do_action( 'astra_single_post_meta_before' );\nastra_single_get_post_meta();\ndo_action( 'astra_single_post_meta_after' );<\/code><\/pre>\n\n\n\nFor this tutorial, I put the post meta after the content and the after-content hook. With extra lines removed for readability, my single-layout.php<\/em> file now looks like:<\/p>\n\n\n\n<?php\n\/**\n * Template for Single post\n *\n * @package Astra\n * @author Astra\n * @copyright Copyright (c) 2019, Astra\n * @link https:\/\/wpastra.com\/\n * @since Astra 1.0.0\n *\/\n?>\n<div <?php astra_blog_layout_class( 'single-layout-1' ); ?>>\n <?php astra_single_header_before(); ?>\n <header class=\"entry-header <?php astra_entry_header_class(); ?>\">\n <?php astra_single_header_top(); ?> \n <?php astra_blog_post_thumbnail_and_title_order(); ?>\n <?php astra_single_header_bottom(); ?>\n <\/header><!-- .entry-header -->\n <?php astra_single_header_after(); ?>\n <div class=\"entry-content clear\" itemprop=\"text\">\n <?php astra_entry_content_before(); ?>\n <?php the_content(); ?>\n <?php\n astra_edit_post_link(\n sprintf(\n \/* translators: %s: Name of current post *\/\n esc_html__( 'Edit %s', 'astra' ),\n the_title('<span class=\"screen-reader-text\">\"','\"<\/span>',false)\n ),\n '<span class=\"edit-link\">',\n '<\/span>'\n );\n ?>\n <?php astra_entry_content_after(); ?> \n <?php\n do_action( 'astra_single_post_meta_before' );\n astra_single_get_post_meta();\n do_action( 'astra_single_post_meta_after' );\n ?> \n <?php\n wp_link_pages(\n array(\n 'before' => '<div class=\"page-links\">' . esc_html(\n astra_default_strings(\n 'string-single-page-links-before', false\n )\n ),\n 'after' => '<\/div>',\n 'link_before' => '<span class=\"page-link\">',\n 'link_after' => '<\/span>',\n )\n );\n ?>\n <\/div><!-- .entry-content .clear -->\n<\/div><\/code><\/pre>\n\n\n\nDue to the way Astra lays out their code in this file, I had to wrap the lines in <?php<\/em> and ?><\/em>. This tells the code that I want it to be treated as PHP and not html.<\/p>\n\n\n\nSo you're actually adding this to single-layout.php<\/em>:<\/p>\n\n\n\n<?php\ndo_action( 'astra_single_post_meta_before' );\nastra_single_get_post_meta();\ndo_action( 'astra_single_post_meta_after' );\n?><\/code><\/pre>\n\n\n\n<\/p>\n","protected":false},"excerpt":{"rendered":"
This tutorial is in response to a question from one of our readers. This tutorial will work with both the free and paid versions of Astra. We also have a tutorial on customizing the post meta appearance for Astra. You’ll need to have a child theme active. See our tutorial on building a child theme<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[19],"yoast_head":"\n
How To Move Astra Post Meta<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n