Community Forums › Forums › Archived Forums › Design Tips and Tricks › How to customize with custom post types?
Tagged: Custom Post Type, navigation
- This topic has 5 replies, 3 voices, and was last updated 11 years, 5 months ago by
arush.
-
AuthorPosts
-
August 20, 2013 at 8:36 pm #57832
lucaslem
MemberI am a front end designer who is just starting to get more involved with backend development, and contrary to advice I have been given about starting without a Framework, this is my first site with Genesis. While I have found the manual useful to get off the ground, it feels the studiopress site is lacking in more advanced tutorials especially with regards to functional customization (beyond design).
I am working from the sample child theme of the framework to create a site offering workshops in the field of social services. I have successfully created a "workshops" custom post type (as well as a custom taxonomy of "workshop-categories") as a plugin rather than in functions.php. This will be used on a bilingual multisite, hence the plugin for future translation.
I also have a "workshops" page which is successfully displaying the workshops posts as a list (regardless of whether I have the template set to "default", "blog", or "archive" — does it matter??)
Things have gone very slowly, but relatively well to get to that point, but it has been a confusing mess ever since. Sadly most tutorials I come across online are not helpful when using genesis and its completely unique file structure. So here are my questions:
- I am using the workshop custom categories in a secondary navigation as a filter, but I would like this menu to display only from the workshops page.
- I have managed to remove the post meta and post info from the workshops list on the workshops page, but I would also like to remove it from the custom categories list (ex: list which displays when "families" workshop category is clicked).
- "Filed Under" displays blank from CPT even though categories are assigned.
- While the "workshops" page menu item appears along side of all the other primary nav menu items, it does not get assigned a class of "current-menu-item". Why not and how can this be fixed?
I am assuming there are some templates I may need to create, but at this point I am not sure what requires a template and what simply needs a few lines of conditional code. Many thanks in advance for any help or specific resources.
Apologies if there are too many different questions in a single post, but they are all rather related and I wasn't too sure how to break it all up. Please don't hesitate to let me know if there is a better way to post in the forum.
August 20, 2013 at 9:36 pm #57838Brad Dalton
ParticipantThere's over 650 code snippets for Genesis on my site if that helps.
Here's the answers to your questions:
1. You can use the Genesis Simple Menu's plugin or PHP code.
2. Install the Genesis Simple Edits plugin or remove it using PHP or CSS code
3. Use this code in the single_cpt.php file:remove_action( 'genesis_before_post_content', 'genesis_post_info' );
4. You might want to post this as a single question in a new post.
Here's an excellent post for creating a Portfolio Custom Post Type.
August 21, 2013 at 3:34 pm #58026lucaslem
MemberBrad, many thanks for the incredibly valuable information.
- Your code snippet worked perfectly for the one page, but in fact I was not quite accurate in my need for the secondary nav. I need it to appear on all the cpt related sections. So I need the conditional to be something like this (which obviously doesn't work but will hopefully illustrate what I'm after:`add_action('template_redirect', 'remove_subnav_specific_pages');
function remove_subnav_specific_pages() {
if ( !is_page('345') )
OR
if ( !is_workshop-categories )
OR
if ( !is_single_post_type ('workshops')
remove_action('genesis_after_header', 'genesis_do_subnav');
}`The plugin was useful for the categories, but the dropdown does not display on the single cpt edit screen (I assume it needs another item in the supports arg?). In any case, for the posts I think it would make more sense to resolve this with code anyway as making that selection each time a workshop is created seems quite excessive. I suppose I can just add this in my single_cpt.php, which does work (not sure what is best practice):
add_action( 'genesis_after_header', 'genesis_do_subnav' );
As for the main workshops page (domain.com/workshops) it does not show the "edit page" button on the front end admin bar. I don't understand why (and this is true regardless of which template I select). I assume this has to do with the template hierarchy, but I'm finding templates extremely confusing/frustrating in Genesis compared to a standard wordpress theme (in which the php files are easier to comprehend for someone coming from an HTML/CSS background). If you could point me towards documentation which explains the structure I would appreciate it.
- Great, will definitely do that!
- That snippet isn't working for some reason.
- It's really a minor detail at this point so I will create a new thread a little further down the line
I found this and assume it might be a good general read http://designsbynickthegeek.com/tag/genesis-explained
Thank-you for your patience.
August 21, 2013 at 5:26 pm #58068Brad Dalton
Participant3. The loop hooks are different for XHTML and HTML 5 enabled child themes.
http://my.studiopress.com/docs/hook-reference/
http://my.studiopress.com/docs/filter-reference/
Nick works for Copyblogger media and is staff at StudioPress so he knows his stuff and offers a great resource for Genesis users. http://designsbynickthegeek.com
I find the code in the existing SP child themes the best to use when customizing a theme. I own the Pro Plus Package so have access to hundreds of code snippets which all work on Genesis.
The conditional tag for custom post types is:
if ( 'portfolio' == get_post_type() || 'video' == get_post_type() || is_page() )
Above is 2 custom post types and the conditional for pages.
Here's a tutorial and snippets you can modify for conditional nav menus
You may need to change your settings for the Edit Link. Go to Your Profile > Show Toolbar when viewing site
Or the Edit shortcode may have been removed from the post Info field using Genesis Simple Edits
[post_edit] - Post edit link (visible to admins)
Sub Nav for CPT's
You can use the Genesis Simple Menus plugin and add support for CPT's or use PHP code in a custom function in your child themes functions.php file.
add_post_type_support( 'video', 'genesis-simple-menus' );
What template do you need?
Best to ask one question at a time from now on so people can focus on the one solution for you as its better that way. Always happy to help.
August 21, 2013 at 9:04 pm #58113lucaslem
MemberRegarding the hooks I am indeed using the Genesis 2.0 Sample Child Theme with HTML 5.0 enabled, so not sure what's going on there but I will do some digging. I'm certain it has to do with my shoddy coding.
The issue for the subnav got resolved in a single block of code (thanks a million for the cpt conditional tag which I had come across but had made a few syntax errors!). This way the sub nav appears in all the places I wanted (workshops archive page, workshops categories, and single workshop):
add_action('template_redirect', 'remove_subnav_specific_pages'); function remove_subnav_specific_pages() { if ( 'workshops' !== get_post_type()) remove_action('genesis_after_header', 'genesis_do_subnav'); }
Brandon, I can't thank you enough for taking the time. There is certainly a lot there to get me on the right track. Will explore your proposed resources. Noted for separate questions.
August 28, 2013 at 9:33 pm #59395arush
MemberHi,
I don't know if this is the best place to post this question, but I'll do so anyway. I'm trying to conditionally display the time and date a post was published. I'm working with the Metro child theme, and have enabled post formats support. But for the shorter posts like statuses and asides, I want to display the time and date a post was published, while for standard posts I don't want to display the time and date at all. Is this possible?
Thanks.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.