【问题标题】:Retrieve data from page using specific template (Wordpress)使用特定模板(Wordpress)从页面中检索数据
【发布时间】:2015-05-21 10:11:22
【问题描述】:

我正在创建一个投资组合,它需要使用特定模板显示和缩略图、标题和指向所有其他投资组合页面的链接。

这是我目前所拥有的,它可以很好地检索页面标题和特色图片。我正在努力检索该页面的链接,因为the_permalink() 只是返回您当前所在页面的链接。

<?php foreach ( $builtins as $page ) : ?>
            <div class="fw-col-xs-6 fw-col-md-3  remove-column-padding ">
                <div class="casestudy">
                    <?php if (has_post_thumbnail( $page->ID ) ): ?>
                        <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $page->ID ), 'single-post-thumbnail' ); ?>
                        <div class="block" style="background: url('<?php echo $image[0]; ?>')">
                            <h3>
                                <a href="<?php echo apply_filters( 'the_permalink', $page->post_permalink, $page->ID ); ?>" title="<?php echo apply_filters( 'the_title', $page->post_title, $page->ID ); ?>">
                                    <?php echo apply_filters( 'the_title', $page->post_title, $page->ID ); ?>
                                    <span></span>
                                </a>
                            </h3>
                        </div>
                    <?php endif; ?>
                </div>
            </div>
        <?php endforeach; ?>

【问题讨论】:

  • $builtins 你能告诉我 print_r 结果吗 print_r($builtins);
  • print_r 在循环之外
  • 感谢@JunaidAhmed 的回复,很长的回复codeshare.io/4tQN6
  • 任何帮助将不胜感激,仍然坚持这个。
  • codeshare.io/4tQN6 不工作

标签: php wordpress templates


【解决方案1】:

谢谢朱奈德,

我找到了答案,get_permalink($page-&gt;ID); 成功了!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-01
    • 1970-01-01
    • 2017-08-31
    • 1970-01-01
    • 1970-01-01
    • 2018-10-04
    • 2011-11-19
    • 1970-01-01
    相关资源
    最近更新 更多