How to Edit which Post Meta Items Display

Home » Tutorials » Theme Tutorials » How to Edit which Post Meta Items Display

If you want to edit which meta values are displayed at the bottom of posts as shown in the screenshot below, please use one of the following methods:

Edit-post-meta

As you can see in the screenshot above, there are 4 data points that can be modified:

  • Date
  • Comment (number of comments)
  • Permalink (i.e, the “read more”)
  • Edit post reflected as a # sign (only visible to admin, allows quick access to edit the post)

Method 1: Updating Post Meta Per Content Area

Suppose for a specific content area, you wish to modify which post meta values are displayed. To do this, follow these instructions:

1) Open the misc-functions.php file* and find the section that corresponds to the content area you wish to change.

*Based on version of your framework, The path of misc-functions.php is either inc/functions/misc-functions.php or framework/functions/misc-functions.php

2) Within the content area, there will be a snippet of code such as this:

<?php gab_postmeta(); ?>

3) Now, in the order shown on the screenshot above, each value can be interpreted as true by default. If you wish to disable a value, then you could replace the snippet above with any of the below:

To disable Date:

<?php gab_postmeta(false,true,true,true); ?>

To disable Comments:

<?php gab_postmeta(true,false,true,true); ?>

To disable Permalink:

<?php gab_postmeta(true,true,false,true); ?>

To disable Edit Post (# sign)

<?php gab_postmeta(true,true,true,false); ?>

As you can see, it’s simply a matter of converting the relevant value to ‘false’ to disable it. You can do this for 1 or more values.

Method 2: Updating Post Meta Site-Wide

IMPORTANT: Editing the post meta requires updating a Gabfire framework core file. YOU are responsible for the update and ensuring you backup your site prior to making such changes. In practice, we highly recommend NOT updating Gabfire framework core files.

1) FTP to your theme directory, and proceed to the following path:

inc/functions/misc-functions.php (in older themes) OR

framework/functions/misc-functions.php (more recent themes)

2) Within that file, search for and replace the section that looks like below with what is provided below:

Note: Within this code, the change made is the value ” = true” to ” = false”. If you want to display a specific value, keep that value as true.

// execute post meta
function gab_postmeta($date = false,$comment = false,$permalink = false,$edit  = false) {
	echo '<span>';
		echo (true === $date) ? get_the_date() . ' / ' : "";
		(true === $comment) ? comments_popup_link(__('No Comment','source'), __('1 Comment','source'), __('% Comments','source')) : "";
		echo (true === $permalink) ?  gab_permalink() : "";
		(true === $edit) ? edit_post_link(__('#','source'),' ','') : "";
	echo '</span>';
}

LEAVE A COMMENT