Tagged: custom template, post type
- AuthorPosts
- November 12, 2016 at 07:39 #7974
DawnParticipantI’m working with my own custom theme and I’d like to add a custom template for the Gmedia Gallery, Album, and Items pages. How do I do that?
November 12, 2016 at 18:13 #7984
RattusKeymasterHello, I’ll be glad to help you.
Here is how to add theme templates for custom post types: https://codex.wordpress.org/Post_Type_TemplatesGmedia create few post types in WordPress:
1) “gmedia” – for single gmedia items
2) “gmedia_album” – for album pages
3) “gmedia_gallery” – for gallery pagesAll logic for displaying these custom posts placed in ‘grand-media/inc/frontend.filters.php’ file. Let me know if you need some Filters or Actions to be added to the code, so you could use them in your theme.
November 13, 2016 at 17:29 #8008
DawnParticipantShould I just be able to create those within the root of my theme or do I need to locate them somewhere different?
November 13, 2016 at 19:03 #8011
DawnParticipantOkay found the answer to my previous question but now I’m looking for guidance on how to access the custom fields created for an Album, as well as the album description.
November 14, 2016 at 00:28 #8017
RattusKeymasterFor ‘single-gmedia_album.php’ file:
if('gmedia_album' == $post->post_type){ global $gmDB; $gmedia_term_id = get_post_meta($post->ID, '_gmedia_term_ID', true); $gmedia_term = $gmDB->get_term($gmedia_term_id); echo apply_filters('the_content', $gmedia_term->description); /* Album Description */ $gmedia_term_meta = $gmDB->get_metadata('gmedia_term', $gmedia_term_id); foreach($gmedia_term_meta as $meta_key => $meta_value){ if($meta_key[0] == '_'){ continue; } /* Skip protected meta */ echo "{$meta_key}: {$meta_value[0]}" /* $meta_key - is custom field name; $meta_value - is array of values for the custom field name. */ } }November 14, 2016 at 06:04 #8028
DawnParticipantThank you!
Worked perfectly!
November 16, 2016 at 21:29 #8116
RattusKeymasterHey, can you post link to your work when it will be done?
- AuthorPosts
- The forum ‘Troubleshooting’ is closed to new topics and replies.
