Skip to content

Instantly share code, notes, and snippets.

@j0lvera
Last active January 2, 2016 00:59
Show Gist options
  • Save j0lvera/8227340 to your computer and use it in GitHub Desktop.
Save j0lvera/8227340 to your computer and use it in GitHub Desktop.
Info for add custom fields on Berkel

How to add custom fields

To add a custom field, we need to edit 3 files, these are described below

to edit page displays

/newsite/wp-content/themes/CherryFramework/loop/loop-single-portfolio.php

to edit portfolio options

/newsite/wp-content/themes/CherryFramework/includes/theme-portfoliometa.php

to edit custom locals

/newsite/wp-content/themes/CherryFramework/includes/locals.php

--

An example of a custom field added are between those lines below:

/* custom field */
/* end of custom field */

Notice that if the custom field is not populated, it doesn't show on the front page

I'm going to add the snippets that need to be edited here:

loop-single-portfolio.php

$portfolioMotor  = get_post_meta($post->ID, 'tz_portfolio_motor', true);
$portfolioCustom  = get_post_meta($post->ID, 'tz_portfolio_custom', true);

if (/* custom field*/ !empty($portfolioCustom) || !empty($portfolioMotor) || /* end of custom field */ !empty($portfolioClient) || !empty($portfolioDate) || !empty($portfolioInfo) || !empty($portfolioURL)) {
    echo '<ul class="portfolio-meta-list">';
}

if (!empty($portfolioCustom)) {
    echo '<li>';
    echo '<strong class="portfolio-meta-key">' . theme_locals("custom").":". '</strong>';
	echo '<span>' . $portfolioCustom . '</span><br />';
	echo '</li>';
}

if (!empty($portfolioMotor)) {
	echo '<li>';
	echo '<strong class="portfolio-meta-key">' . theme_locals("motor").":". '</strong>';
	echo '<span>' . $portfolioMotor . '</span><br />';
	echo '</li>';
}

if (/* custom field */ !empty($portfolioCustom) || !empty($portfolioMotor) || /* end of custom field */ !empty($portfolioClient) || !empty($portfolioDate) || !empty($portfolioInfo) || !empty($portfolioURL)) {
	echo '</ul>';
}?>

theme-portfoliometa.php

array(
   'name' => 'custom',
   'desc' => "custom_desc",
   'id' => $prefix . 'portfolio_custom',
   'type' => 'text',
   'std' => ''
), 

array(
   'name' => 'motor',
   'desc' => "motor_desc",
   'id' => $prefix . 'portfolio_motor',
   'type' => 'text',
   'std' => ''
)

locals.php

'motor_desc' => __('Input the motor', $domain),
'motor' => __('Motor', $domain),

'custom_desc' => __('Input the custom field, or whatever text you want here', $domain),
'custom' => __('Custom', $domain), /* this needs to be the name of the custom field */

and that's all, I'm going to add this text to the video

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment