0

I have a WordPress theme that I am working with called "Forte". Yes, it is a premium theme. I have reached out to the developer but apparently he doesn't really want to help in this situation. Well I need to change the "portfolio" slug to something else. "Portfolio" doesn't really work at all with the website I am working on. In the past what I've done is find ‘rewrite’ => array(“slug” => “portfolio”), in functions.php and I would change it to ‘rewrite’ => array(“slug” => “NEW-SLUG-NAME”),. However, in this theme the developer seems to do it differently. Below is the code in a file called pix_post-types.php which seems to handle this. I am not a PHP developer but I can do a good deal of editing and understand it more-or-less. I would really appreciate some help!

<?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' ),
  ));

}

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

?>
  • Had you tried changing rewrite argument to that? It seems to be fair assumption to me... – Rarst Oct 24 '13 at 21:47
  • @Rarst in fact I have but it didn't work. – Adriano C R Oct 24 '13 at 23:01
  • 1
    Re-save your Permalinks after changing the name and slug. – Brad Dalton Jan 10 '14 at 5:08
2

Re-save your Permalinks after changing the name and slug from portfolio

Looks like you need to add this line to your code

'rewrite'      => array( 'slug' => 'portfolio', 'with_front' => false ),

And change this to true

'public'       => true,
0

The slug is stored in this line:

register_post_type( 'portfolio' , $args );

Also I recommend change and names (they are shown in admin).

  • I tried changing that to the "test" and all the other instances of "portfolio" name and then resaved permalinks and tried clicking one of the portfolio items and I get a 404 error :/ – Adriano C R Oct 24 '13 at 23:03
  • Did you rebuild .htaccess file? You can do that by going to Settings -> Permalinks and hit Save changes button – Lukas J. Oct 27 '13 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.