Tagged: Custom Post Type, gallery, taxonomy
-
AuthorPosts
-
March 4, 2015 at 5:48 pm #405915
I wanted to outline the procedure for creating a custom post type and using it with Enfold theme. So here it goes.
Here’s how to create a custom post type in Enfold and use it for storing, categorizing and displaying galleries (photo galleries in my case). I wanted to use the portfolio type solely for my projects and needed to have another post type for galleries. And I wanted to keep the taxonomies separate as well.
So below I have described the process for creating a CPT using a plugin and modifying the functions.php file to include some code to use the CPT. All this is based on the support I received from the Enfold team so my contribution is simply to bring it all together in one place. With many thanks to the support team, I hope you find it useful.
Install a plugin that lets you create custom post types (CPT). I used Types. Once installed, go to it and click Add Custom Post Type button.
You will be taken to Add Custom Post Type screen. This is where you define your CPT. Here’s what I did.
You could name these as you like but keep the names handy as you’ll use them later in the functions.php file.
Once you have defined the CPT, you can scroll down to set additional settings. Make sure the profile is public and tags taxonomy is selected.
Save the custom post.
You’ll back at the main page of the Types plugin.
Next click Add Custom Taxonomy button to create categories so you can categorize your work.
Type you categories names at the Add New Taxonomy screen. See this example:
Once you have defined your taxonomies, you can save them and get back out to the main screen.
You should have something like this:
Let’s now make changes to the functions.php file so we can use this CPT. I’ve used a child theme so the changes are made there.
Add this code to the file:
/
* to support displaying custom post types */add_theme_support(‘add_avia_builder_post_type_option’);
add_theme_support(‘avia_template_builder_custom_post_type_grid’);/* to display advanced portfolio setting */
add_filter(‘avf_builder_boxes’,’enable_boxes_on_posts’);
function enable_boxes_on_posts($boxes) {
$boxes[] = array( ‘title’ =>__(‘Avia Layout Builder’,’avia_framework’ ), ‘id’=>’avia_builder’, ‘page’=>array(‘portfolio’, ‘page’, ‘post’,’gallery-items’), ‘context’=>’normal’, ‘expandable’=>true );
$boxes[] = array( ‘title’ =>__(‘Layout’,’avia_framework’ ), ‘id’=>’layout’, ‘page’=>array(‘portfolio’, ‘page’, ‘post’, ‘gallery-items’), ‘context’=>’side’, ‘priority’=>’low’);
$boxes[] = array( ‘title’ =>__(‘Additional Portfolio Settings’,’avia_framework’ ), ‘id’=>’preview’, ‘page’=>array(‘portfolio’, ‘gallery-items’), ‘context’=>’normal’, ‘priority’=>’high’ );return $boxes;
}`Notice the “gallery-items”? They are the same we created earlier. The code also enables the Advanced Layout Editor. Save the file. That’s it.
Now once all this is done, just create a gallery item from the Gallery Items on the left side.
In order to display the contents in this CPT and the categories, choose your desired portfolio or masonry in a page and you’ll be presented the with some additional choices. See Below:
Now you can choose to display the post type so you can choose the newly created CPT (Gallery Items) and Gallery Categories.
You have now duplicated the portfolio post type and all its features.
Keep in mind that if you have existing content that used categories, you may have to change some settings, especially the categories and post types in order for them to display properly.
Hope you have fun and find this useful.
Regards,
- This topic was modified 9 years, 8 months ago by Tameez. Reason: Some html coding issue
March 4, 2015 at 10:10 pm #406082Hi Tameez!
Thanks for sharing.
Regards,
ElliottMarch 8, 2015 at 9:28 pm #407758Hi Tameez, I am very interested in this procedure, I installed the code in my child theme, set the “slug”, created custom content in my portofolios.
If I created a page with a portfolio gallery (Avia builder), it works … except that any subsequent change of that page is no longer possible.
I need to create a new page with the changes to see the actual changes.
Any idea?Regards.
JeanEDIT : in fact it works, I made a mistake in how to create custom tags and correcting it is functional. Super trick Tameez. Thank you very much!!!
- This reply was modified 9 years, 8 months ago by freepixelweb.
March 9, 2015 at 11:24 am #407970Hi, I tested this solution since yesterday, there are problems in the presentation of pages and Breadcrumb.
I made a summary page of a category (types) with a gallery Masonry, it works.
If I go on the portfolio page (Types) I’m in a context of Blog post and not a Portfolio single page.
If I use the Page Builder Avia in my Portfolio entry (Types) I find this layout in the final page … but the processing time is long (it’s because I use a child theme, in fact with Enfold it’s normal)..
In this situation if I click in the breadcrumb on the summary category I do not go on the summary page Masonry but in an archive page Blog …
Another problem there is no navigation Prev / Next in the portofolio page.
In short this is all a bit mixed and we do not find a real behavior Enfold Portfolio … for me it’s not good.Regards.
Jean- This reply was modified 9 years, 8 months ago by freepixelweb.
March 11, 2015 at 4:03 pm #409912Hi!
Not sure if we will be able to help you here but can you send us a link to your page and take a screenshot highlighting what your trying to do?
Best regards,
ElliottMarch 11, 2015 at 5:17 pm #409971Hi, sorry Elliot I do not have URLs to offer, I test locally (Mamp).
Now I am testing a solution with another theme (Avada) sorry. I have to produce two websites in the coming month and I do not have time to look for a solution with Enfold.
I have a third project to come later, and I would look if I find a solution with Enfold. It I do not have URLs to offer, I test locally (Mamp). Now I am testing a solution with another theme (Avada) sorry. I have to produce two sites in the coming month and I do not have time to look for a solution with Enfold.
I have a third project to come later, and I would look if I find a solution with Enfold. It would add a function multiple Portfolios as with a kind extension CTM, but totaly integrated to Enfold (nav prev/next, Avia builder, related content, etc).Regards.
Jean- This reply was modified 9 years, 8 months ago by freepixelweb.
March 11, 2015 at 7:14 pm #410041Hi Jean,
Yes, there are some limitations as I am discovering as well. The lack of Next and Previous navigation is pretty obvious and there are others. This procedure is just a hack and it let me have just-enough capability. I own other themes where both portfolios and galleries are supported (with their own categories) out of the box (I shouldn’t name them here) and they are pretty darn good. The reasons I don’t use them is because they are cumbersome to use.
Regards,
Tameez
-
AuthorPosts
- The topic ‘Procedure for adding custom post type and enabling it for use’ is closed to new replies.