Hello,
Use following PHP snippet to display post excerpt when description is empty.
/**
* Show post excerpt when post description is empty.
*/
function gd_snippet_210619_custom_field_output_post_excerpt( $html, $location, $cf, $output ) {
global $gd_post;
if ( ! empty( $gd_post ) && empty( $gd_post->post_content ) && ! empty( $gd_post->post_excerpt ) ) {
$post_excerpt = $gd_post->post_excerpt;
$extra_fields = ! empty( $cf['extra_fields'] ) ? stripslashes_deep( maybe_unserialize( $cf['extra_fields'] ) ) : NULL;
$field_icon = geodir_field_icon_proccess( $cf );
$output = geodir_field_output_process( $output );
if ( strpos( $field_icon, 'http' ) !== false ) {
$field_icon_af = '';
} elseif ( $field_icon == '' ) {
$field_icon_af = '';
} else {
$field_icon_af = $field_icon;
$field_icon = '';
}
$max_height = ! empty( $output['fade'] ) ? absint( $output['fade'] ) . "px" : '';
$max_height_style = $max_height ? " style='max-height:$max_height;overflow:hidden;' " : '';
$html = '<div class="geodir_post_meta ' . $cf['css_class'] . ' geodir-field-' . $cf['htmlvar_name'] . '" ' . $max_height_style . '>';
if ( $output == '' || isset( $output['icon'] ) ) $html .= '<span class="geodir_post_meta_icon geodir-i-text" style="' . $field_icon . '">' . $field_icon_af;
if ( $output == '' || isset( $output['label'] ) ) $html .= trim( $cf['frontend_title'] ) != '' ? '<span class="geodir_post_meta_title" >'.__( $cf['frontend_title'], 'geodirectory') . ': '.'</span>' : '';
if ( $output == '' || isset( $output['icon'] ) ) $html .= '</span>';
if ( $output == '' || isset( $output['value'] ) ) {
$content = wp_strip_all_tags( do_shortcode( wpautop( stripslashes( $post_excerpt ) ) ) );
if ( $content ) {
if ( ! empty( $output['limit'] ) ) {
$content = wp_trim_words( $content, absint( $output['limit'] ), '' );
}
$html .= $content;
if ( isset( $output['more'] ) ) {
$more_text = empty( $output['more'] ) ? __( "Read more...","geodirectory" ) : __( $output['more'], "geodirectory" );
$link_class = ! empty( $output['fade'] ) ? 'gd-read-more-fade' : '';
$html .= " <a href='" . get_permalink( $gd_post->ID ) . "#" . $cf['htmlvar_name'] . "' class='gd-read-more $link_class'>" . esc_attr( $more_text ) . "</a>";
}
}
}
$html .= '</div>';
}
return $html;
}
add_filter( 'geodir_custom_field_output_textarea_var_post_content', 'gd_snippet_210619_custom_field_output_post_excerpt', 100, 4 );
Kiran