-
Hi everyone,
As we have received a few requests for a tutorial on changing the default theme’s portfolio_item slug we are willing to show the whole process in a step by step guide.
If you are just changing just the slug name (portfolio_item) you don’t need to go through the whole process below, simply change the slug into your \wp-content\plugins\fortuna_portfolio_cpt\fortuna_portfolio_cpt.php
'rewrite' => array('slug' => 'portfolio_item'),Change the “portfolio_item” to what you like, then flush your rewrite rules (switching back to regular permalinks in – Settings -> Permalinks and then back to the fancy ones should do the job too).
If you want to change the name of the whole custom post type or duplicate the existing one here’s what you need to do:
In the example below we shall change the “portfolio” Custom Post Type to “book” just for the sake of this tutorial.1. We make a copy of the plugin file found in \wp-content\plugins\fortuna_portfolio_cpt\fortuna_portfolio_cpt.php – this is the plugin responsible for registering the Portfolio custom post type. We shall name it and place it in a directory according to its new name “book” so: \wp-content\plugins\fortuna_book_cpt\fortuna_book_cpt.php
2. We edit the newly created fortuna_book_cpt.php file and replace all occurrences of “portfolio” with “book”. At this point in order to finalize the registration of our new “Book” custom post type we should go to WP Dashboard and activate our “Fortuna Book CPT” plugin and deactivate the “Fortuna Portfolio CPT”.
3. Next we need to setup the correct templates for this newly created post type. We can copy over the portfolio templates into your Child Theme and rename them accordingly followin the new “book” nomenclature.
We’ll need:
single-portfolio.php– single-book.php
taxonomy-portfolio_category.php- taxonomy-book_category.phpportfolio-three-column.php– book-three-column.php4. If you will be using the portfolio-three-column.php (the Template with the category filter dropdown) you will need to update inside of it the call to the “boc_get_portfolio_items” method, replace it with “boc_get_book_items” then edit your Child theme’s functions.php (create it in the Child theme’s root folder if it doesn’t exist) file and add this new method:
if( ! function_exists( 'boc_get_book_items' ) ) { function boc_get_book_items($limit = 10, $order_by = 'rand', $order = 'DESC', $category='', $paged = 1) { $args = array( 'ignore_sticky_posts' => 0, 'post_type' => 'book', 'posts_per_page' => (int)$limit, 'orderby'=> $order_by, 'order'=> $order, 'paged' => $paged, 'book_category' => $category, ); $query = new WP_Query($args); wp_reset_postdata(); return $query; } }You also need to change at the top of the template in the comments the template name:
Template Name: Books Page, then the references to the new CPT category taxonomy:get_terms('book_category')and
get_the_terms($post->ID, 'book_category')-
This topic was modified 10 years by
BlueOwl.
-
This topic was modified 10 years by
BlueOwl.
-
This topic was modified 10 years by
BlueOwl.
-
This topic was modified 10 years by
BlueOwl.
-
This topic was modified 10 years by
BlueOwl.
-
This topic was modified 10 years by
BlueOwl.
-
This topic was modified 10 years by
BlueOwl.
-
This topic was modified 10 years by
BlueOwl.
-
This topic was modified 10 years by
BlueOwl.
-
This topic was modified 10 years by
BlueOwl.
-
This topic was modified 10 years by
BlueOwl.
-
This topic was modified 10 years by
BlueOwl.
-
This topic was modified 10 years by
- Theme support is offered to verified customers only. To post a topic go to your Theme Category and add your question at the page bottom.
Theme Categories
Recent Topics
- Alea updates
- Why "Fortune" theme is no longer available?
- PHP 8.1 Error
- Issue with WPB editor icons
- Issue with Icons and Text Alignment for Arabic Content
- Installing and Activating Plugin Fortuna Portfolio CPT (1/8)
- Testimonials page is blank
- warning boc_framework line 905
- Transparent header issue without changes
- Slider Revolution error