Wordpress页面图像目录

时间:2014-02-01 06:20:37

标签: php wordpress

所以..我正在使用Wordpress创建一个网页..我通过使用模板

编辑页面来显示内容
<?php
/*
Template Name: Pages
*/
?>

<?php get_header(); ?>

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
        <?php the_content(); ?>
    <?php endwhile; else: ?>
        <p>Sorry, no posts matched your criteria. Please try again.</p>
    <?php endif; ?>

<?php get_footer(); ?>

但是Wordpress Pages Textarea在这个块中过滤我的php代码

<img src="<?php echo get_template_directory_uri(); ?>/images/pinterest.png" alt=""/>

所以我做的是用绝对URL替换它,如src =“http:// localhost / wordpress / theme ....等等

但我认为这是一种正确的方法。有什么建议/想法吗?

1 个答案:

答案 0 :(得分:0)

以下是我将如何操作,创建一个短代码,您可以通过在functions.php中添加一个代码段来使用..这个网站提供了一个很好的例子

http://wpsnacks.com/wordpress-code-snippets/how-to-create-a-shortcode-to-display-the-wordpress-theme-path/