ACF field integration?
-
I have a popular posts loop in my homepage.php that uses post_html to build out the markup. I am trying to get an ACF text field text field in there and all attempts leave me with the same text showing on each post.
Hoping there is some documentation I missed or I am just missing something super obvious.
This is my code
page functions.php
/**
* Parses custom content tags in WordPress Popular Posts.
*
* @param string $html The HTML markup from the plugin.
* @param integer $post_id The post/page ID.
* @return string
*/
function wpp_parse_tags_in_popular_posts( $html, $post_id ){
if ( false !== strpos($html, ‘{battery_price}’) ) {
$acf_price = get_field( ‘battery_price’, $post_id );
if ( $acf_price ) {
$html = str_replace( ‘{battery_price}’, $acf_price, $html );
}
else {
$html = str_replace( ‘{battery_price}’, ”, $html );
}
}
return $html;}
page homepage.php
<?php
$args = array(
‘order_by’ => ‘views’,
‘post_type’ => ‘post’,
‘cat’ => ‘178,-3,-162,-26’,
‘limit’ => 3,
‘range’ => ‘all’,
‘thumbnail_width’ => 100,
‘thumbnail_height’ => 75,
‘post_html’ => ‘<div class=”flex-wheel-other”>
<div class=”wheel-small-box -wheel”>
<figure class=”thumb”>
{thumb}
</figure>
</div>
<div class=”wheel-small-box”>
<p>{text_title}</p>
<p class=”price”>{battery_price} บาท</p>
<p>({views} views)</p>
</div>
<div class=”wheel-small-box -num”>
<div class=”number-other”>
1
</div>
</div>
</div>
‘
);wpp_get_mostpopular($args );
?>battery_price not show acf field post 🙁
The page I need help with: [log in to see the link]
The topic ‘ACF field integration?’ is closed to new replies.