Community Forums › Forums › Archived Forums › General Discussion › Custom Post Type in Genesis?
Tagged: Custom Post Types Customizations
- This topic has 5 replies, 2 voices, and was last updated 7 years, 1 month ago by Greyvolf.
-
AuthorPosts
-
February 9, 2017 at 11:16 am #200857GreyvolfMember
Hey there! I'm a newbie in WP and I was wondering if you guys can point me to some tutorials on how to create Custom Post Types in Genesis? I would want them to be hierarchical. I created a CTP but I can't figure out how to make it hierarchical. If I have other links on it and I don't know how to redirect them to another post/page within that CPT. (my-custom-post/other-link/other-link and so on)
February 9, 2017 at 12:42 pm #200863Victor FontModeratorWhen you create CPTs while using Genesis, make sure you add the appropriate post type support to functions.php
add_post_type_support( 'portfolio', array( 'genesis-seo', 'genesis-scripts', 'genesis-layouts', 'genesis-rel-author', 'genesis-adjacent-entry-nav' ) );
Change 'portfolio' to the the name of your post type.
As for your questions about links and hierarchy, I'm not clear about what you're asking.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?February 9, 2017 at 1:23 pm #200865GreyvolfMemberFirst of all, thank you, Victor, for your prompt reply, appreciate it. I wonder what's the worst that could happen if I don't add the support you mentioned? I wouldn't want my author to be confused by those fields. Secondly to make my issue more clearly understood I'm going to give a quick example.
Before that, I want to mention that I know very well HTML CSS and JS, so I don't have a problem with creating the mark-up, styles and interaction. Ok, here goes:
Let's say I have a portfolio CPT and there I have 2 links - "My Work" and "My hobbies". Now, where do I create those additional pages/posts and how do I link them to my CPT? Should I create another template(s) in order to show them? Another CPT? This is the point where I'm stuck.
So far I have created the page-portfolio.php template where I show all my portfolio CPT and a single-portfolio.php template where I have the code on how the CPT should look like.
Thank you in advance!
February 9, 2017 at 2:11 pm #200866Victor FontModeratorCPTs can have their own taxonomies. I would create My Works and My Hobbies as categories. They work the same as regular categories.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?February 9, 2017 at 2:13 pm #200867GreyvolfMemberOk, so I figured one way to do it, I don't know if it's the best way but I'm going to elaborate it in case someone else encounters the same problem.
The following is the order I created the whole CPT scenario:
1. Created a CPT with hierarchical option set to true.
2. Created a few Custom Fields.
3. Added 3 CPT to have something to work with - "Portfolio", "My Work", "My Hobbies"
4. Added a custom taxonomy - "parent-page" and assigned that to the "Portfolio" CPT. The others are child pages to "Portfolio". You set the parent in the Page Attributes.
5. Created a query that only shows on only those CPT that have the "parent-page" category. (using page-portfolio.php template). So at this stage you should only see the "Portfolio" displayed. "My work" and "My Hobbies" are hidden.
6. Then in the Custom fields you insert a link and to the href the path should be "/my-work" or "/my-hobbies"That did it.
February 9, 2017 at 2:30 pm #200869GreyvolfMemberThank you, Victor! Your solution is better since I can have different templates for "My Work" and "My Hobbies". With my solution above I'll be stuck with the same template as the "Portfolio". I'll just have to figure out the appropriate query to show them...
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.