Reply To: Help

#3069
mashwebdesign
mashwebdesign
Participant

Alright mate, starting to understand a little bit more now.

I am trying to concatenate the custom fields onto $pageposts->content see below:

add_filter( ‘asp_pagepost_results’, ‘asp_show_the_post_type’, 1, 1 );

function asp_show_the_post_type( $pageposts ) {
foreach ($pageposts as $k=>$v) {

// Get the post categories
$html .= ‘<div class=”further-info”>’;

if(get_field(‘from-to-or-at’) == ‘from-to’):

$html .= ‘<p class=”fromto”><i class=”fa fa-road”></i>From: ‘ . get_field(‘from’) . ‘ To: ‘. get_field(‘to’) .'</p>’;

elseif(get_field(‘from-to-or-at’) == ‘at’):

$html .= ‘<p class=”fromto”><i class=”fa fa-road”></i> AT:’ .get_field(‘at’) . ‘</p>’;

endif;

$html .= ‘<p class=”delay-type”><i class=”fa fa-car”></i> ‘ . get_field(‘delay_type’) . ‘</p>’;

$countin = 0;

foreach($incidenttype as $value):

$countin++;

if($countin == 1):

$html .= ‘<p><i class=”fa fa-cogs”></i> Incident Type: ‘ . $value . ‘</p>’;

else:

$html .= ‘<p>’ . $value . ‘</p>’;

endif;

endforeach;

$html .= ‘<p><i class=”fa fa-clock-o”></i> ‘ . get_the_time() . ‘</p>’;

if(get_field(‘avoid’)):

$html .= ‘<p class=”avoid-p”><i class=”fa fa-warning”></i> Avoid</p>’;

endif;

$html .= ‘</div>’;

$cats = “”;

// Modify the post title
$pageposts[$k]->content = $pageposts[$k]->content . $html;

}
var_dump($pageposts);
return $pageposts;
}

It works however it doesn’t get the custom fields? Any idea why it doesn’t?

Cheers