Have a template that uses the following and trying to replace the post thumbnail with a custom image (using ACF).
<?php
/**
* Grid Layout Template - 1
*
* @author RadiusTheme
* @since 1.0
* @version 1.0
*/
use RTThePostGridHelpersFns;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$pID = get_the_ID();
$excerpt = Fns::get_the_excerpt( $pID, $data );
$title = Fns::get_the_title( $pID, $data );
/**
* Get post link markup
* $link_start, $link_end, $readmore_link_start, $readmore_link_end
*/
$post_link = Fns::get_post_link( $pID, $data );
extract( $post_link );
if ( is_array( $data['grid_column'] ) && ! empty( $data['grid_column'] ) ) {
foreach ( $data['grid_column'] as $key => $value ) {
if ( $data['grid_column'][ $key ] == '1' ) {
$data['grid_column'][ $key ] = '12';
} elseif ( $data['grid_column'][ $key ] == '2' ) {
$data['grid_column'][ $key ] = '6';
} elseif ( $data['grid_column'][ $key ] == '3' ) {
$data['grid_column'][ $key ] = '4';
} elseif ( $data['grid_column'][ $key ] == '4' ) {
$data['grid_column'][ $key ] = '3';
} elseif ( $data['grid_column'][ $key ] == '5' ) {
$data['grid_column'][ $key ] = '24';
} elseif ( $data['grid_column'][ $key ] == '6' ) {
$data['grid_column'][ $key ] = '2';
}
}
}
// Grid Column:
$grid_column_desktop = ( isset( $data['grid_column']['lg'] ) && '' != $data['grid_column']['lg'] ) ? $data['grid_column']['lg'] : '4';
$grid_column_tab = ( isset( $data['grid_column']['md'] ) && '' != $data['grid_column']['md'] ) ? $data['grid_column']['md'] : '6';
$grid_column_mobile = ( isset( $data['grid_column']['sm'] ) && '' != $data['grid_column']['sm'] ) ? $data['grid_column']['sm'] : '12';
$col_class = "rt-col-md-{$grid_column_desktop} rt-col-sm-{$grid_column_tab} rt-col-xs-{$grid_column_mobile}";
// Column Dynamic Class
$column_classes = [];
$column_classes[] .= $data['hover_animation'];
$column_classes[] .= 'rt-grid-item';
if ( 'masonry' == $data['layout_style'] ) {
$column_classes[] .= 'masonry-grid-item';
}
?>
<div <?php post_class( esc_attr( $col_class . ' ' . implode( ' ', $column_classes ) ) ); ?>
data-id="<?php echo esc_attr( $pID ); ?>">
<div class="rt-holder tpg-post-holder">
<div class="rt-detail rt-el-content-wrapper">
<?php
if ( 'show' == $data['show_thumb'] ) :
$has_thumbnail = has_post_thumbnail() ? 'has-thumbnail' : 'has-no-thumbnail';
?>
<div class="rt-img-holder tpg-el-image-wrap <?php echo esc_attr( $has_thumbnail ); ?>">
<?php Fns::get_post_thumbnail( $pID, $data, $link_start, $link_end ); ?>
</div>
<?php endif; ?>
I’m able to pull the image in, but unable to get the post link to attach/wrap the image using this, but not the link:
<div <?php post_class( esc_attr( $col_class . ' ' . implode( ' ', $column_classes ) ) ); ?>
data-id="<?php echo esc_attr( $pID ); ?>">
<div class="rt-holder tpg-post-holder">
<div class="rt-detail rt-el-content-wrapper">
<?php
if ( 'show' == $data['show_thumb'] ) :
$has_thumbnail = has_post_thumbnail() ? 'has-thumbnail' : 'has-no-thumbnail';
?>
<div class="rt-img-holder tpg-el-image-wrap <?php echo esc_attr( $has_thumbnail ); ?>">
<?php if ($imageID) {
// creates the img tag
echo wp_get_attachment_image($imageID, $size, $link_start, $link_end );
} ?>
</div>
<?php endif; ?>
Any suggestions appreciated. I tried using the $pID variable, but it threw an error.
New contributor
Larry Hirsch is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.