【问题标题】:How to customize wordpress portfolio grid to replace attributes output with text of single portfolio?如何自定义 wordpress 投资组合网格以用单个投资组合的文本替换属性输出?
【发布时间】:2015-09-09 14:20:46
【问题描述】:

我是 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 变量的内容。我敢打赌这是可能的。

如何获取每个作品集帖子的文本字段的内容并将其发布到那里?我知道 the_content() 或 get_the_content() 函数会以某种方式发挥作用,但它是如何完成的呢?任何帮助表示赞赏!

【问题讨论】:

  • 你试过 $output .= '

    '。 get_the_content()。 '

    '; ?

标签: php wordpress customization


【解决方案1】:

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

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

这假设“投资组合项目的文本”实际上在您的数据库中保存为 WP content

顺便说一句,我不知道为什么在这种情况下你要把所有的东西都连接成一个字符串...PHP 的一个奇妙之处在于它能够与标准 HTML 结合起来:

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

【讨论】:

  • 非常简单!哇!我认为很难获得正确的投资组合 ID,否则……我开始喜欢 php。
猜你喜欢
  • 2021-05-13
  • 1970-01-01
  • 2011-11-16
  • 2011-07-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-02
相关资源
最近更新 更多