【问题标题】:linking to a the pdf folder within my wordpress child theme链接到我的 wordpress 子主题中的 pdf 文件夹
【发布时间】:2012-09-01 03:06:55
【问题描述】:

我想链接到我的子主题的 pdf 文件夹中的一个 pdf,目前我正在使用以下 php

<?php echo esc_url( home_url( '/wp-content/themes/child-theme/pdf/bar.pdf' ) ); ?>

并且想知道是否有更优雅的方式来做到这一点,不涉及包括 wp-content/themes ?

【问题讨论】:

  • 为什么不直接/wp-content/themes/child-theme/pdf/bar.pdf
  • 您只希望链接指向 WP 文件夹之外的 PDF 目录吗?
  • @paul 是的,那会很好

标签: php wordpress


【解决方案1】:

达到您的孩子主题的最佳方式是通过get_stylesheet_directory_uri()

<?php echo get_stylesheet_directory_uri() . '/pdf/bar.pdf'; ?>

您可以在 Codex 中找到更多信息:get stylesheet directory uri

【讨论】:

    【解决方案2】:

    只需在您的根目录中创建一个名为 pdf 的新目录

    echo '<a href="/pdf/doc.pdf">Anchor Text</a>';
    

    但是,我不确定这会带来什么真正的好处。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-02
      • 2023-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-02
      相关资源
      最近更新 更多