Viewing 7 posts - 1 through 7 (of 7 total)
Viewing 7 posts - 1 through 7 (of 7 total)
- The forum ‘Troubleshooting’ is closed to new topics and replies.
Forum closed. Use forum at Wordpress.org: Gmedia Support
Forum
Tagged: custom template, post type
I’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?
Hello, I’ll be glad to help you.
Here is how to add theme templates for custom post types: https://codex.wordpress.org/Post_Type_Templates
Gmedia create few post types in WordPress:
1) “gmedia” – for single gmedia items
2) “gmedia_album” – for album pages
3) “gmedia_gallery” – for gallery pages
All 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.
Should I just be able to create those within the root of my theme or do I need to locate them somewhere different?
Okay 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.
For ‘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. */
}
}
Thank you!
Worked perfectly!
Hey, can you post link to your work when it will be done?