【问题标题】:WP ACF echoes variable even if not wanted即使不需要,WP ACF 也会回显变量
【发布时间】:2018-01-14 13:31:16
【问题描述】:

我有一个奇怪的问题,我以前做过很多次同样的事情。 但出于某种原因,这一领域根本不想合作......

            <?php if (have_rows('subfamilies_product_changes')) :

            while ( have_rows('subfamilies_product_changes') ) : the_row();

            $url = the_sub_field('subfamilies_product_changes_link');

            echo    "<div class='support-lahko'>";
            echo        "<div class='support-logo'>";
            echo        the_date( 'Y-m-d' );
            echo        "</div>";
            echo        "<div class='news-name-product'>";
            echo        "<h3 style='vertical-align: middle;'>" . the_sub_field('subfamilies_product_changes_title') ."</h3>";
            echo        "</div>";
            echo        "<div class='news-desc'>";
            echo        "</div>";
            echo    "</div>";
            echo "<br>";


            endwhile;
            endif; 

看来,无论我将&lt;a&gt; 标签放在哪里,这个脚本都会继续运行,并且出于某种原因,将$url = the_sub_field('subfamilies_product_changes_link'); 的链接回显到它所定义的位置。当我尝试做类似&lt;a href=' . $url . '&gt; 之类的事情时,它仍然会在看似随机的地方回显&lt;p&gt; 标签中的url。

这是我将$url 放入href 时发生的情况: http://imgur.com/a/7AQsl

href 保持为空,而 wp 只是在定义它的地方回显 url。图片中的文字都不是链接。

我只需要将 url 回显到 href 中,这样我就可以将链接迭代到 pdf 文件中。

the_sub_field('subfamilies_product_changes_title')

按预期生成文本:测试更改。

【问题讨论】:

  • 你需要使用get_sub_field()
  • ..... 哎呀,是的。谢谢
  • 没问题的朋友。
  • 如果你愿意,你可以把它作为答案提出来

标签: php html wordpress advanced-custom-fields


【解决方案1】:

简答 - 使用 get_sub_field();

the_sub_field() 立即输出它。

很高兴它有帮助 - 有时它是破坏我们一天的最小的事情。

【讨论】:

    猜你喜欢
    • 2016-05-20
    • 2023-03-25
    • 2012-04-15
    • 1970-01-01
    • 2015-03-21
    • 1970-01-01
    • 1970-01-01
    • 2012-04-18
    • 1970-01-01
    相关资源
    最近更新 更多