定义文件夹位置以重新调用它

时间:2011-04-28 作者:Screaming Violet

我正在创建一个来自wp框架的子主题,并在其标题中使用

<?php echo IMAGES . \'/favicon.ico\'; ?>
调用保存图像的文件夹。

如何定义或创建位置,以便使用回声图像调用它?

如果我能将图像文件夹位置保存为图像(如果我记得它是一个字符串?)我可以对其他信息也这样做吗?

2 个回复
最合适的回答,由SO网友:Chris_O 整理而成

许多WordPress框架包括助手函数和预定义的文件夹位置。WP框架编码很好,但需要学习和检查代码才能找到文档。

在文件核心中。php定义了许多常量,但我没有看到图像,但定义了THEME\\u IMAGE,因此IMAMGE可能引用子主题目录中的IMAGES文件夹。

以下是可供您使用的常量列表:

WP Framework V 3.6 core。php:

function wpf_initial_constants() {  
    // Sets the File path to the current parent theme\'s directory.
    define( \'PARENT_THEME_DIR\', TEMPLATEPATH );

    // Sets the URI path to the current parent theme\'s directory.
    define( \'PARENT_THEME_URI\', get_template_directory_uri() );

    // Sets the File path to the current parent theme\'s directory.
    define( \'CHILD_THEME_DIR\', STYLESHEETPATH );

    // Sets the URI path to the current child theme\'s directory.
    define( \'CHILD_THEME_URI\', get_stylesheet_directory_uri() );

    // Sets the file path to WP Framework
    define( \'WPF_DIR\', PARENT_THEME_DIR . \'/framework\' );

    // Sets the URI path to WP Framework
    define( \'WPF_URI\', PARENT_THEME_URI . \'/framework\' );

    // Sets the file path to extensions
    define( \'WPF_EXT_DIR\', WPF_DIR . \'/extensions\' );

    // Sets the URI path to extensions
    define( \'WPF_EXT_URI\', WPF_URI . \'/extensions\' );
}

/**
 * Templating constants that you can override before WP Framework is loaded.
 *
 * @since 0.3.0
 *
 * @return void
 */
function wpf_templating_constants() {
    // Sets a unique ID for the theme.
    if ( !defined( \'THEME_ID\' ) )
        define( \'THEME_ID\', \'wpf_\' . get_template() );

    // Sets the default theme options db name
    if ( !defined( \'THEME_OPTIONS\' ) )
        define( \'THEME_OPTIONS\', \'theme_options\' );

    // Sets relative paths for the default directories/paths
    if ( !defined( \'THEME_LIBRARY\' ) )
        define( \'THEME_LIBRARY\', \'/library\' );

    if ( !defined( \'THEME_I18N\' ) )
        define( \'THEME_I18N\', THEME_LIBRARY . \'/languages\' );

    if ( !defined( \'THEME_FUNC\' ) )
        define( \'THEME_FUNC\', THEME_LIBRARY . \'/functions\' );

    if ( !defined( \'THEME_IMG\' ) )
        define( \'THEME_IMG\', THEME_LIBRARY . \'/images\' );

    if ( !defined( \'THEME_CSS\' ) )
        define( \'THEME_CSS\', THEME_LIBRARY . \'/css\' );

    if ( !defined( \'THEME_JS\' ) )
        define( \'THEME_JS\', THEME_LIBRARY . \'/js\' );

    // Sets the default custom header image
    if ( !defined( \'DEFAULT_HEADER_IMAGE\' ) )
        define( \'DEFAULT_HEADER_IMAGE\', get_theme_part( THEME_IMG . \'/custom-header.gif\' ) );
}

SO网友:Chip Bennett

如果需要定义/重新定义常量:

define( \'IMAGES\', \'path/to/images/directory\' );
如果你需要回音parent-theme\\images:

<?php echo get_template_direcory_uri() . \'/images\'; ?>
如果你需要回音child-theme\\images:

<?php echo get_stylesheet_direcory_uri() . \'/images\'; ?>
还是你需要做点别的?

结束

相关推荐

Embed phpBB within Wordpress?

使用Wordpress v3。1.1设置新CMS<BBPress并不令人满意,因此我选择使用phpBB作为论坛平台。我有wordpress bones laid out, 也确定了大胆的主题(Site5).<我想为论坛保留这个主题,所以我需要了解如何在Wordpress中嵌入phpBB论坛。How do you embed a phpBB forum within a Wordpress theme?<我听说了WP United的好消息,但他们的网站现在已经关闭了超过三分之一,作者也没有