如何自定义 wordpress 投资组合网格以用单个投资组合的文本替换属性输出?

How to customize wordpress portfolio grid to replace attributes output with text of single portfolio?

我是 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>';

我想输出单个投资组合文本字段的内容,而不是 $on_attributes 变量的内容。我打赌这是可能的。

如何获取每个投资组合文本字段的内容 post 并将其放在那里?我知道 the_content() 或 get_the_content() 函数会以某种方式发挥作用,但如何准确完成呢?感谢您的帮助!

您已经在问题中提到了答案:

'<h3 class="portfolio-attributes">' . get_the_content() . '</h3>';

这假设 "text of a portfolio item" 在您的数据库中实际保存为 WP content

作为旁注,我不确定为什么在这种情况下您将所有内容连接成一个字符串...PHP 的一个美妙之处在于能够使用标准 HTML:

<h3 class="portfolio-attributes"><?php the_content(); ?></h3>