我是一个php新手,但必须以某种方式解决以下问题:
在我的…portfolio_grid.php中,我成功地理解了这一部分:
$output .= '
<a class="classic-portfolio-box normal-type-prt'.$colorize_fx_class.'" href="'.get_permalink($post_id).'" title="'.get_the_title().'"'.$colorize_hover.'></a>
<div class="portfolio-box">
<div class="portfolio-naming">
<h2 class="portfolio-title">'.get_the_title().'</h2>';
if( !empty($on_attributes) ){
$output .= '
<h3 class="portfolio-attributes">'.$on_attributes.'</h3>';
}
$output .= '</div>
</div>
<img src="'.$image[0].'" width="'.$image[1].'" height="'.$image[2].'" alt="'.get_the_title().'" />
';
负责出现在我的投资组合框中的内容。现在我想更改以下细节:
$output .= '
<h3 class="portfolio-attributes">'.$on_attributes.'</h3>';
我想用单个portfolio文本字段的内容代替$on_attributes变量的内容。我打赌这是可能的。
我如何获取每个单独的投资组合帖子的文本字段的内容,并把它放在那里?我知道以某种方式the_content()或get_the_content()函数将发挥作用,但它究竟是如何做到的?任何帮助都是感激的!
你已经在问题中提到了答案:
'<h3 class="portfolio-attributes">' . get_the_content() . '</h3>';
这假设"作品集项目的文本"实际上被保存为数据库中的WP content
。
作为旁注,我不确定为什么在这种情况下您要将所有内容连接为字符串…PHP的一个奇妙之处在于它可以与标准HTML结合在一起:
<h3 class="portfolio-attributes"><?php the_content(); ?></h3>