我正在尝试在最近的帖子小部件上显示一个数字。首先我添加一个自定义字段并调用“kekoa”并设置值,而不是将代码放在最近的帖子小部件功能上。
// Check if post has post thumbnail.
if ( has_post_thumbnail() ) :
$html .= '<div class="mainumber33">' . get_post_meta($post->ID, "yeniyazinumarasi", true) . '</div>';
$yeniyazinumarasi= $html;
echo $yeniyazinumarasi;
$html .= '<a class="rpwe-img" href="' . esc_url( get_permalink() ) . '" rel="bookmark">';
if ( $image ) :
$html .= '<img class="' . esc_attr( $args['thumb_align'] ) . ' rpwe-thumb" src="' . esc_url( $image ) . '" alt="' . esc_attr( get_the_title() ) . '">';
else :
$html .= get_the_post_thumbnail( get_the_ID(),
array( $args['thumb_width'], $args['thumb_height'] ),
array(
'class' => $args['thumb_align'] . ' rpwe-thumb the-post-thumbnail',
'alt' => esc_attr( get_the_title() )
)
);
endif;
$html .= '</a>';
我可以看到css框,但我看不到我设置的数字。
UPDATE.FİXED
// Check if post has post thumbnail.
if ( has_post_thumbnail() ) :
$html .= '<div class="mainumber33">' . get_post_meta(get_the_ID(), "kekoa", true) . '</div>';
$html .= '<a class="rpwe-img" href="' . esc_url( get_permalink() ) . '" rel="bookmark">';
if ( $image ) :
$html .= '<img class="' . esc_attr( $args['thumb_align'] ) . ' rpwe-thumb" src="' . esc_url( $image ) . '" alt="' . esc_attr( get_the_title() ) . '">';
else :
$html .= get_the_post_thumbnail( get_the_ID(),
array( $args['thumb_width'], $args['thumb_height'] ),
array(
'class' => $args['thumb_align'] . ' rpwe-thumb the-post-thumbnail',
'alt' => esc_attr( get_the_title() )
)
);
endif;
$html .= '</a>';
答案 0 :(得分:1)
if ( has_post_thumbnail() ) :
$html = '<div class="mainumber33">';
$html .= get_post_meta($post->ID, "kekoa", true);
$html .= '</div>';
$html .= '<a class="rpwe-img" href="' . esc_url( get_permalink() ) . '" rel="bookmark">';
if ( $image ) :
$html .= '<img class="' . esc_attr( $args['thumb_align'] ) . ' rpwe-thumb" src="' . esc_url( $image ) . '" alt="' . esc_attr( get_the_title() ) . '">';
else :
$html .= get_the_post_thumbnail( get_the_ID(),
array( $args['thumb_width'], $args['thumb_height'] ),
array(
'class' => $args['thumb_align'] . ' rpwe-thumb the-post-thumbnail',
'alt' => esc_attr( get_the_title() )
)
);
endif;
$html .= '</a>';
你有一堆拼写错误