Rename "Portfolio" slug?

时间:2013-10-24 作者:Adriano C R

我有一个我正在处理的WordPress主题,叫做“Forte”。是的,这是一个高级主题。我已经联系过开发人员,但显然他并不想在这种情况下提供帮助。好吧,我需要把“投资组合”这个词换成其他的词。“公文包”对我正在开发的网站根本不起作用。过去我所做的就是找到‘rewrite’ => array(“slug” => “portfolio”), 在里面functions.php 我会把它改成‘rewrite’ => array(“slug” => “NEW-SLUG-NAME”),. 然而,在这个主题中,开发人员的做法似乎有所不同。下面是一个名为pix_post-types.php 这似乎可以解决这个问题。我不是PHP开发人员,但我可以做大量的编辑工作,或多或少地理解它。我真的很感激你的帮助!

<?php
add_action(\'init\', \'register_testimonial\');

function register_testimonial() {
  $args = array(
    \'labels\' => array(
  \'name\' => __( \'Testimonials\' ), 
  \'singular_name\' => __( \'Testimonial\' ),
  \'add_new\' => _x(\'Add new\', \'testimonial\'),
  \'add_new_item\' => __(\'Add a new testimonial\'), 
  \'edit_item\' => __(\'Edit testimonial\'),
  \'new_item\' => __(\'New testimonial\'),
  \'view_item\' => __(\'View testimonial\'),
  ),
\'capability_type\' => \'page\',
\'has_archive\' => false,
\'hierarchical\' => false,
\'menu_position\' => 22,
\'public\' => false,
\'singular_label\' => __(\'Testimonial\'),
\'show_ui\' => true,
\'supports\' => array(
  \'title\',
  \'thumbnail\',
  \'editor\',
  \'custom-fields\',
  \'revisions\')
  );

  register_post_type( \'testimonial\' , $args );
}

add_action(\'init\', \'register_portfolio\');

function register_portfolio() {
  $args = array(
\'labels\' => array(
  \'name\' => __( \'Portfolio\' ), 
  \'singular_name\' => __( \'Portfolio\' ),
  \'add_new\' => _x(\'Add new\', \'portfolio\'),
  \'add_new_item\' => __(\'Add a new item\'), 
  \'edit_item\' => __(\'Edit item\'),
  \'new_item\' => __(\'New item\'),
  \'view_item\' => __(\'View item\'),
  ),
\'capability_type\' => \'page\',
\'has_archive\' => true,
\'hierarchical\' => false,
\'menu_position\' => 20,
\'public\' => true,
\'rewrite\' => true,
\'singular_label\' => __(\'Portfolio\'),
\'show_ui\' => true,
\'supports\' => array(
  \'title\',
  \'thumbnail\',
  \'editor\',
  \'excerpt\',
  \'trackbacks\',
  \'custom-fields\',
  \'comments\',
  \'revisions\')
  );

      register_post_type( \'portfolio\' , $args );
    }

add_action( \'init\', \'create_portfolio_taxonomies\', 0 );

//create two taxonomies, genres and writers for the post type "book"
function create_portfolio_taxonomies() 
{
  // Add new taxonomy, make it hierarchical (like categories)
  $labels = array(
\'name\' => _x( \'Galleries\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'Gallery\', \'taxonomy singular name\' ),
\'search_items\' =>  __( \'Search Gallery\' ),
\'all_items\' => __( \'All Galleries\' ),
\'parent_item\' => __( \'Parent Gallery\' ),
\'parent_item_colon\' => __( \'Parent Gallery:\' ),
\'edit_item\' => __( \'Edit Gallery\' ), 
\'update_item\' => __( \'Update Gallery\' ),
\'add_new_item\' => __( \'Add New Gallery\' ),
\'new_item_name\' => __( \'New Gallery Name\' ),
\'menu_name\' => __( \'Galleries\' ),
  );    

  register_taxonomy(\'gallery\',array(\'portfolio\'), array(
\'hierarchical\' => true,
\'labels\' => $labels,
\'show_ui\' => true,
\'query_var\' => true,
\'rewrite\' => array(\'hierarchical\' => true )
  ));

  // Add new taxonomy, NOT hierarchical (like tags)
  $labels = array(
\'name\' => _x( \'Tags\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'Tag\', \'taxonomy singular name\' ),
\'search_items\' =>  __( \'Search tags\' ),
\'popular_items\' => __( \'Popular tags\' ),
\'all_items\' => __( \'All tags\' ),
\'parent_item\' => null,
\'parent_item_colon\' => null,
\'edit_item\' => __( \'Edit tag\' ), 
\'update_item\' => __( \'Update tag\' ),
\'add_new_item\' => __( \'Add New tag\' ),
\'new_item_name\' => __( \'New tag name\' ),
\'separate_items_with_commas\' => __( \'Separate tags with commas. They will be used for filtering portfolio items\' ),
\'add_or_remove_items\' => __( \'Add or remove tags\' ),
\'choose_from_most_used\' => __( \'Choose from the most used tags\' ),
\'menu_name\' => __( \'Tags\' ),
 ); 

  register_taxonomy(\'portfolio_tag\',\'portfolio\',array(
\'hierarchical\' => false,
\'labels\' => $labels,
\'show_ui\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'portfolio_tag\' ),
  ));

}

            /*=========================================================================================    */

?>

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

更改公文包中的名称和slug后,重新保存永久链接

看起来您需要将此行添加到代码中

\'rewrite\'      => array( \'slug\' => \'portfolio\', \'with_front\' => false ),
并将此更改为true

\'public\'       => true,

SO网友:Lukas J.

段塞存储在该行中:

register_post_type( \'portfolio\' , $args );
此外,我建议更改和名称(它们显示在admin中)。

结束

相关推荐

提前注册Taxonomy,以便可以在unctions.php和admin-ajax.php中使用它

这是对this post, 概述在函数中无法使用get\\u terms函数的原因。php(实际上是通过ajax/admin\\u ajax.php调用)。我可以在任何帖子、任何页面上获取术语(自定义税),除了在我的ajax函数中。在转储get\\u terms的值时,我收到了可怕的“分类法不存在”错误。问题是,在调用函数查找术语后,分类法被注册。问题是,如何尽早注册税务以便使用此功能?注册自定义帖子类型和分类的代码是函数中的第一个。php(通过外部php提供,以保持functions.php干净)/**