Home › Forums › Backend Issues (wp-admin) › Help Trying To Get Custom Fields To Display On Front-End
Hello,
We’re relative newbs when it comes to using ACF. Our developer is on vacation for another 4 weeks and we’re trying to add 4 custom fields (text) to our pages. We’ve already created the fields in the Custom Fields area but we are having issues trying to figure out how to get it to display on the front-end.
Can anyone tell us how to add these 4 custom text fields to display on the front-end. It would be greatly appreciated. New fields are text fields called “store” “brand” “price” & “upc”.
Thank you!
Here is our current customization for this page:
<?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_separate_style', trailingslashit(get_stylesheet_directory_uri()) . 'ctc-style.css', array());
}
endif;
if (!function_exists('child_theme_configurator_js')):
function child_theme_configurator_js()
{
wp_enqueue_script('jquery');
wp_enqueue_script('chld_thm_cfg_separate_script', get_stylesheet_directory_uri() . '/custom.js', array('jquery'), "3432.0.0");
}
endif;
add_action('wp_enqueue_scripts', 'child_theme_configurator_css');
add_action('wp_enqueue_scripts', 'child_theme_configurator_js');
// END ENQUEUE PARENT ACTION
if (!function_exists('category_top_view')):
function category_top_view()
{
if (is_category()) {
?>
<div style="background-color: white;">
<div class="container">
<div style="padding:20px 40px;">
<?php
echo do_shortcode("[oceanwp_breadcrumb]");
?>
<h1 style="text-transform: uppercase;font-weight: 700;">
<?php
echo single_cat_title();
?>
</h1>
<?php
$breakpoint = 0;
$thiscat = get_term(get_query_var('cat'), 'category');
$subcategories = get_terms('category', 'parent=' . get_query_var('cat'));
if (empty($subcategories) && $thiscat->parent != 0) {
$subcategories = get_terms('category', 'parent=' . $thiscat->parent . '');
}
$items = '';
if (!empty($subcategories)) {
foreach ($subcategories as $subcat) {
if ($thiscat->term_id == $subcat->term_id) $current = ' current-cat'; else $current = '';
$items .= '<li class="cat-item cat-item-' . $subcat->term_id . $current . '"><a href="' . get_category_link($subcat->term_id) . '" title="' . $subcat->description . '">' . $subcat->name . '</a></li>';
}
echo "<ul class='top-subcategory-container'>$items</ul>";
}
unset($subcategories, $subcat, $thiscat, $items);
?>
</div>
</div>
</div>
<?php
}
}
endif;
add_action('ocean_before_content_wrap', 'category_top_view');
/*
* Get the deal button before post content
*/
if (!function_exists('get_the_deal')):
function get_the_deal()
{
$dealURL = get_field("deals_url");
if (!empty($dealURL)) {
// check if deal is expired
$isExpired = false;
$dealExpireDate = get_field("expiry_date", false, false);
if (!empty($dealExpireDate)) {
$hour = get_field("expiry_hour");
$minute = get_field("expiry_minute");
$dealExpireDate = new DateTime($dealExpireDate);
$dealExpireDate->setTime($hour, $minute, 0);
$currentDate = new DateTime("now");
if ($dealExpireDate < $currentDate) {
$isExpired = true;
}
}
?>
<div class="get-deal-container">
<a href="<?php echo $dealURL ?>" class="btn btn-getdeal" target="_blank">Get Deal / Details
<i class="fa fa-chevron-right"></i>
</a>
</div>
<?php
if (!empty(get_field('recent_update'))) {
?>
<p style="font-size: 110%;margin-top: 8px;">
<strong><span style="color: #ff0000;">Update</span>:
<?php
the_field('recent_update');
?>
</strong>
</p>
<?php
} else if ($isExpired) {
?>
<p style="font-size: 110%;margin-top: 8px;">
<strong>Update: Deal Expired
</strong>
</p>
<?php
}
}
}
endif;
add_action('ocean_before_single_post_content', 'get_the_deal');
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We’re reaching out to our multilingual users to ask for help in translating ACF 6.1. Help make sure the latest features are available in your language here: https://t.co/TkEc2Exd6U
— Advanced Custom Fields (@wp_acf) May 22, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.