Okay
  Public Ticket #2144400
Add Custom Post Type
Closed

Comments

  •  1
    acidoverride started the conversation

    Hi,

    So I'm looking at adding some custom post types to my Bifrost themed site. Also, might be nice to remove the 'Portfolio' post type already there.

    I have looked at this ticket https://neuronthemes.ticksy.com//ticket/2051069/

    I couldn't find the 'widgets' directory in the 'includes' folder? Is this due to it been an older version? Whats the best way of adding them now?

  •  675
    Neuron replied

    Hi,

    Actually they are on the same path, simply make sure to look into the neuron-core-bifrost plugin not in the theme.

    Kind Regards


    Subscribe to our newsletter to get the latest updates about NeuronThemes and join our community Facebook Group.

  •  1
    acidoverride replied

    Aahhh awesome, thanks for that. Will these changes be lost if the plugin updates?

    Could I use the instances of 'portfolio' to create new CPTs by duplicating the code? Does the code needed only appear in neuron-core-bifrost > functions.php and neuron-core-bifrost > includes > widgets > posts > base.php?

    I also want the option to display the excerpt and possibly other meta like with the default blog post type. Is this possible? Do I have to create templates for the single pages?

    Thanks

  •  675
    Neuron replied

    Hi,

    I am very sorry for the late reply.

    Basically it's only there, just watch the examples and you'll be able to add the custom post types easily. Unfortunately, there is the only option for the moment, make sure to save the code, until we found a better way to add them.

    Well, there are two types of meta-s, inside and outside. You'll be able to find them both in the bifrost > templates > type portfolio(for portfolios) and so on for the other blog and products. You can modify them on the child theme.

    Kind Regards


    Subscribe to our newsletter to get the latest updates about NeuronThemes and join our community Facebook Group.

  •  1
    acidoverride replied

    No problem, gave me time to do a bit more digging myself.

    What examples are there to watch? That previous ticket is the only thing I could find relating to adding CPTs. Whats best way to add the post type? Use a plugin like CPT UI or add them in the function.php file in my child theme folder? I've had them working already but I am unable to edit each post using elementor. If there is a walk through or video for the process that would be awesome.

    Thanks

  •  675
    Neuron replied

    Hi,

    Sure, feel free to ask for anything you need.

    Sure, the first steps are only to create the custom post types, you can skip that part. Unfortunately there are still no videos, I am sure we'll add something on the future, but I cannot give any date for the moment.

    Make sure to add on the posts type. https://prnt.sc/o49fat

    Feel free to ask for anything you need.

    Kind Regards


    Subscribe to our newsletter to get the latest updates about NeuronThemes and join our community Facebook Group.

  •  1
    acidoverride replied

    Ok so Ive created the CPT in my child theme directory function.php file as I normally would. Works fine!

    I have added the control into the base.php file located in the neuron-core-bifrost > includes >widgets > posts folder.

    I also added the switch option in the base.php file.

    The post type itself is working fine, Ive added the Nueron Post element to a page and added my CPT with no issues. I just dont get the option to build the single page using Elementor, just get the basic WP 'blocks'. Whats the steps to get this working?

    Regarding the meta types. Do I just simply duplicate the blog > type folder in templates? I'm just unsure how it will know to relate to my CPT?

  •  675
    Neuron replied

    Hi,

    1) You can easily enable the Elementor on your Custom Post Types, simply by going on Elementor > Settings and ticking the custom post type you want to enable it. https://prnt.sc/p54033

    2) Well, blog & portfolio and shop both has two types, please check when you include them you can duplicate them there or create a new folder for the type.

    Feel free to ask for anything you need.

    Kind Regards


    Subscribe to our newsletter to get the latest updates about NeuronThemes and join our community Facebook Group.

  •  1
    acidoverride replied

    Awesome, that was easy haha. I even managed to add it's own custom taxonomy :-)

    I just don't see the 'Settings' dropdown where it gives me the option to Inherit or override things like breadcrumbs, footer and header types ect. How can I add this to this specific post type?

    Still a little lost on the adding the meta options to my CPT. So I now have in my child theme folder... templates > cpt1 > type. I've basically duplicated the files in this folder from the blog folder. What bits need changing? Also, the category doesn't show even when the Categories in the Meta drop down in Elementor is set to show. I'm guessing this is due to this CPT having its own set of categories right? When I try 'Query' a category in Elementor, I only get the Portfolio Categories to choose from.

  • elyawhoo replied

    Good day! I Found that after new awesome update we lost all our CPT settings, and file structure and code of Neuron fas changed....Now trying to find places in code where to insert our CPTs :) 

    Please help!

  •  1
    acidoverride replied

    plugins > neuron-core-bifrost > includes > widgets > posts > base.php

    That's where I added the code to include CPTs within the core theme I believe (ref https://neuronthemes.ticksy.com//ticket/2051069/).

    I just created the CPT itself in my child theme folder functions.php file or you can use CPT UI plugin.

    Still struggling getting the meta options working in Elementor though.

  • elyawhoo replied

    i've just added code for my CPTs everywhere i found....i can select cpt in Posts widgetб but no post displaying...

  •  675
    Neuron replied

    Hi Guys,

    Elyawhoo make sure to add them on the posts_type on the switch post type, maybe that's what you're missing. https://prnt.sc/o49h7v

    Acidoverride, there's a switch statement on isotope(if you're using isotope, same works on the carousel). https://prnt.sc/p5r0xm

    See, the $neuron_posts_name variable, that means for example, if you're using books custom post type, the search will be on.

    templates/books/types/meta-outside.php

    So make sure that your php file is on the right location.

    Feel free to ask for anything you need.

    Kind Regards


    Subscribe to our newsletter to get the latest updates about NeuronThemes and join our community Facebook Group.

  •   Neuron replied privately
  •   acidoverride replied privately
  •   Neuron replied privately
  •   acidoverride replied privately
  •  675
    Neuron replied

    Isn't there? What version of Neuron Core you're running? 2.0.0 or 1.0.0?


    Subscribe to our newsletter to get the latest updates about NeuronThemes and join our community Facebook Group.

  •  1
    acidoverride replied

    1.1.0 It's what came with the theme and there's no prompt to update?

  •  675
    Neuron replied

    Well, now the plugin is on 2.0.0, I'm sorry that there was no prompt for update, we tried to mention it on the what's new article.

    https://neuronthemes.com/bifrost/whats-new-in-2-0/ (Go at the bottom)

    Kind Regards


    Subscribe to our newsletter to get the latest updates about NeuronThemes and join our community Facebook Group.

  •  1
    acidoverride replied

    Ok done all that, now I'm lost haha. I have added the term into query.php but something else is obviously missing. I added the switch statement in base.php as before and also added my CPT to the neuron_return_taxonomies function. Is that it for the neuron-core-bifrost files?

    I also recreated the the template folder in my child theme.added to the wavs folder for meta-iside and metta-outside and also created categories-wavs.php in the taxonomy folder.

    Might be worth while listing the files with their paths that need editing?

  •  675
    Neuron replied

    Hi,

    So, I went to my localhost and tested this one again. I will explain the process below.

    1) I created my custom post type called book and it's taxonomy book_category.

    2) I added my post type to the Post Type Option. https://prnt.sc/p8jwdg Location for file is at the plugin Neuron Core Bifrost, so head to neuron-core-bifrost > includes > widgets > posts > options > content > functionality.php

    3) Now, I need to add it on the query too. So copy the control 'posts_query_normal_post'. https://prnt.sc/p8jxw0 - Spot the arrows, there are the places that you need to change from post to your custom post type. 

    After doing that the categories will appear right after we select the book post type. https://prnt.sc/p8jy7i

    Location of file is at neuron-core-bifrost > includes > widgets > posts > options > content > query.php

    4) Now open the base.php at neuron-core-bifrost > includes > widgets > posts > base.php

    On the switch statement add your new type. https://prnt.sc/p8k060

    With these steps we're done on the plugin, we need just a few more on the child theme.

    1) Go to templates and duplicate the folder portfolio, there you have the meta-inside and meta-outside types. 

    2) And the last thing is to duplicate the category file on bifrost > templates > taxonomy. https://prnt.sc/p8k3bo

    I would suggest to duplicate the categories-portfolio.php, after that change it to your taxonomy. https://prnt.sc/p8k41s

    Go back to your meta-inside and meta-outside files and change from portfolio-categories to book-categories. 

    - https://prnt.sc/p8k4i6

    Check it and see if you missed any of the steps.

    Kind Regards


    Subscribe to our newsletter to get the latest updates about NeuronThemes and join our community Facebook Group.

  •  1
    acidoverride replied

    Ok this is awesome haha Thanks!!!

    Having a strange issue though. So got the CPT in place, works fine. Added a couple posts to it. I then added the post type option in functionality.php. I then added the controller posts_query_normal_wavs and also posts_query_metro_wavs in query.php. Selected WAVs in the Post Type drop down in Elementor and weirdly it imports 'Posts'?!?! see attached...

  •  675
    Neuron replied

    Good to knowsmile.png

    Have you added the metro control? Can you please screenshot it, maybe there's anything that you missed.

    See the third answer.

    3) Now, I need to add it on the query too. So copy the control 'posts_query_normal_post'. https://prnt.sc/p8jxw0 - Spot the arrows, there are the places that you need to change from post to your custom post type. 

    After doing that the categories will appear right after we select the book post type. https://prnt.sc/p8jy7i

    You need to do the same for the metro, create a control from the metro of post.

    Kind Regards


    Subscribe to our newsletter to get the latest updates about NeuronThemes and join our community Facebook Group.

  •  1
    acidoverride replied

    No problem. I've screen grabbed all the bits I've added so far.

  •  675
    Neuron replied

    Good to know, there's just one more thing that you need to do in base.php.

    https://prnt.sc/p8r4j1

    Add on switch case your post type and add the control name into variable.

    $neuron_posts_metro_query = $settings['posts_query_metro_product'];

    Otherwise the 4th answersmile.png

    4) Now open the base.php at neuron-core-bifrost > includes > widgets > posts > base.php

    On the switch statement add your new type. https://prnt.sc/p8k060

    With these steps we're done on the plugin, we need just a few more on the child theme.

    Feel free to ask for anything you need.

    Kind Regards


    Subscribe to our newsletter to get the latest updates about NeuronThemes and join our community Facebook Group.

  •  1
    acidoverride replied

    Got it working :-D I must say that guide was just what I needed, I'm sure many other people will find it extremely handy!!

    So now the question is, how do I add the excerpt or any other meta to my CPT?

  •  675
    Neuron replied

    Hi,

    Good to know, feel free to ask for anything you needsmile.png

    On the meta-outside.php or meta-inside.php, simply add the PHP function.

    <?php the_excerpt() ?>

    You can add it anywhere you'd like.

    Feel free to ask for anything you need.

    Kind Regards


    Subscribe to our newsletter to get the latest updates about NeuronThemes and join our community Facebook Group.

  •  1
    acidoverride replied

    Don't I have to add the control $neuron_posts_meta_excerpt to make the Excerpt selectable in the Meta drop down in Elementor?

  •  675
    Neuron replied

    Hi,

    Well, there's a control located in.

    neuron-core-bifrost > includes > widgets > posts > options > content  > meta.php

    https://prnt.sc/p9y6qz

    So, you can simply comment that part or remove the condition completely and you'll have access on the variable.

    $neuron_posts_meta_excerpt

    Feel free to ask for anything you need.

    Kind Regards


    Subscribe to our newsletter to get the latest updates about NeuronThemes and join our community Facebook Group.

  •  1
    acidoverride replied

    Ok so I swapped out 'post' for 'wavs' in the meta.php file and added an if statement to meta-outside.php and I now have a switch in the meta dropdown for excerpts in my CPT..... YAY!! But now I dont have the excerpt switch for 'posts'. So I'm guessing I need to create a control for each post type? But simply duplicating the control posts_meta_excerpt in meta.php and changing the value to 'wavs' doesnt work. Can I add this control to more than one post type?

  •  1
    acidoverride replied

    Cracked it! Had to set_query_var for 'neuron_posts_meta_excerpt_wavs' in includes > widgets > posts > base.php :-)

  •  675
    Neuron replied

    Hooraysmile.png

    Good to know and thank you very much for sharing this with the others.

    Kind Regards


    Subscribe to our newsletter to get the latest updates about NeuronThemes and join our community Facebook Group.