自定义邮政类型档案标题小写

时间:2013-02-22 作者:Nathan Monk

尽管“name”被定义为句子大小写,但我的自定义帖子类型存档标题是否都是小写的?

下面是我正在使用的post类型函数:

function resources_post_type() {
$labels = array(
    \'name\'               => _x( \'Resources, Help & Support\', \'post type general name\' ),
    \'singular_name\'      => _x( \'Resource\', \'post type singular name\' ),
    \'add_new\'            => _x( \'Add New\', \'resources\' ),
    \'add_new_item\'       => __( \'Add New Resource\' ),
    \'edit_item\'          => __( \'Edit Resource\' ),
    \'new_item\'           => __( \'New Resource\' ),
    \'all_items\'          => __( \'All Resources\' ),
    \'view_item\'          => __( \'View Resource\' ),
    \'search_items\'       => __( \'Search Resources\' ),
    \'not_found\'          => __( \'No resources found\' ),
    \'not_found_in_trash\' => __( \'No resources found in the Trash\' ), 
    \'parent_item_colon\'  => \'\',
    \'menu_name\'          => \'Resources\'
);
$args = array(
    \'labels\'        => $labels,
    \'description\'   => \'Holds our resources and resource specific data\',
    \'public\' => true,
    \'show_ui\' => true,
    \'show_in_menu\' => true,
    \'query_var\' => true,
    \'menu_position\' => 5,
    \'has_archive\'   => true,
    \'rewrite\' => array( \'slug\' => \'resources\' ),
    \'supports\' => array(
        \'title\',
        \'editor\',
        \'author\',
        \'thumbnail\',
        \'excerpt\'
    )
);
register_post_type( \'resources\', $args );   
add_action(\'admin_init\', \'flush_rewrite_rules\');
}添加操作(\'init\',\'resources\\u post\\u type\',0);

我用的是论文2.0

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

这不是一个完美的解决方案,但考虑到我迄今为止在这方面所花的钱,这也行。我找不到有问题的代码,但我相信这与论文的核心有关。

因此,我编写了一个过滤器,根据帖子类型更改副本:

function resource_archive_title() {
if (is_post_type_archive(\'resources\')) { ?>
<h1>Resources, Help & Support</h1>
<?php }
}

add_filter(\'thesis_archive_title\', \'resource_archive_title\');
我将为其他帖子类型添加一些其他的语句。

SO网友:keef williams

这是实现这一点的最佳方法,无需为每种类型创建函数。只需将标题传递给函数,就可以轻松地使用ucfirst()函数进行操作。把这个贴在定制版上就行了。php

add_filter(\'thesis_archive_title\', \'captialize_archive_title\');
function captialize_archive_title($title) {
    return ucfirst($title);
}

结束

相关推荐

自定义邮政类型档案标题小写 - 小码农CODE - 行之有效找到问题解决它

自定义邮政类型档案标题小写

时间:2013-02-22 作者:Nathan Monk

尽管“name”被定义为句子大小写,但我的自定义帖子类型存档标题是否都是小写的?

下面是我正在使用的post类型函数:

function resources_post_type() {
$labels = array(
    \'name\'               => _x( \'Resources, Help & Support\', \'post type general name\' ),
    \'singular_name\'      => _x( \'Resource\', \'post type singular name\' ),
    \'add_new\'            => _x( \'Add New\', \'resources\' ),
    \'add_new_item\'       => __( \'Add New Resource\' ),
    \'edit_item\'          => __( \'Edit Resource\' ),
    \'new_item\'           => __( \'New Resource\' ),
    \'all_items\'          => __( \'All Resources\' ),
    \'view_item\'          => __( \'View Resource\' ),
    \'search_items\'       => __( \'Search Resources\' ),
    \'not_found\'          => __( \'No resources found\' ),
    \'not_found_in_trash\' => __( \'No resources found in the Trash\' ), 
    \'parent_item_colon\'  => \'\',
    \'menu_name\'          => \'Resources\'
);
$args = array(
    \'labels\'        => $labels,
    \'description\'   => \'Holds our resources and resource specific data\',
    \'public\' => true,
    \'show_ui\' => true,
    \'show_in_menu\' => true,
    \'query_var\' => true,
    \'menu_position\' => 5,
    \'has_archive\'   => true,
    \'rewrite\' => array( \'slug\' => \'resources\' ),
    \'supports\' => array(
        \'title\',
        \'editor\',
        \'author\',
        \'thumbnail\',
        \'excerpt\'
    )
);
register_post_type( \'resources\', $args );   
add_action(\'admin_init\', \'flush_rewrite_rules\');
}添加操作(\'init\',\'resources\\u post\\u type\',0);

我用的是论文2.0

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

这不是一个完美的解决方案,但考虑到我迄今为止在这方面所花的钱,这也行。我找不到有问题的代码,但我相信这与论文的核心有关。

因此,我编写了一个过滤器,根据帖子类型更改副本:

function resource_archive_title() {
if (is_post_type_archive(\'resources\')) { ?>
<h1>Resources, Help & Support</h1>
<?php }
}

add_filter(\'thesis_archive_title\', \'resource_archive_title\');
我将为其他帖子类型添加一些其他的语句。

SO网友:keef williams

这是实现这一点的最佳方法,无需为每种类型创建函数。只需将标题传递给函数,就可以轻松地使用ucfirst()函数进行操作。把这个贴在定制版上就行了。php

add_filter(\'thesis_archive_title\', \'captialize_archive_title\');
function captialize_archive_title($title) {
    return ucfirst($title);
}

相关推荐