Tagged: x
-
AuthorPosts
-
September 17, 2016 at 4:46 pm #1179618
Hello support team,
I created a custom post type but couldn’t figure out how to make new posts of this type show up as recent post on my blog index page.
Can you tell me how to do that?
Thank you!
September 18, 2016 at 1:09 am #1179894Hi there,
Please follow this thread : https://community.theme.co/forums/topic/custom-post-type-list-page-template/#post-203934
Hope it helps.
September 18, 2016 at 6:39 am #1180077Thanks for the link. I have read this before, but I could not follow the instruction.
As I uderstand it, I have to create a new indx.php and archive.php file for my custom post type in the x-child directory by dublicating the existing index.php file from x-theme directory and rename it with my post type like so: index-{video.php}; archive-{video}.php.“It’s safe to duplicate index.php and it’s template parts for your customization” but my index.php file in wp-content>themes>index.php and wp-content>themes>x>index.php are as good as empty, so I did not see any “template parts” to copy. This is what’s in there:
<?php // ============================================================================= // INDEX.PHP // ----------------------------------------------------------------------------- // Handles output of pages and posts if a more specific template file isn't // present. Must be present for theme to function properly. // // Content is output based on which Stack has been selected in the Customizer. // To view and/or edit the markup of your Stack's index, first go to "views" // inside the "framework" subdirectory. Once inside, find your Stack's folder // and look for a file called "wp-index.php," where you'll be able to find the // appropriate output. // ============================================================================= ?> <?php x_get_view( x_get_stack(), 'wp', 'index' ); ?>
I also do not understand where to copy “all the content you can find in the different files that our portfolio consists of” from.
I would be very greatful if you could give me a little clearer instruction.
Thank you!!
September 18, 2016 at 7:21 am #1180094Hi There,
Please add the following code under functions.php file locates in your child theme:
function x_custom_blog($query) { if( !is_admin() && $query->is_main_query() ) { if( $query->is_home() ) { $query->set('post_type', array( 'post', 'your-post-type' ) ); } } } add_action('pre_get_posts','x_custom_blog');
Replace the
your-post-type
with your post type slug.Hope it helps 🙂
September 18, 2016 at 8:25 am #1180139Thank you, but there is no change visible.
I haven’t created the new index.php and archive.php as mentioned above. Just added the code you have given me into the funktions.php. This is what the funktions.php file in x-child theme looks like:<?php
// ============================================================================= // FUNCTIONS.PHP // ----------------------------------------------------------------------------- // Overwrite or add your own custom functions to X in this file. // ============================================================================= // ============================================================================= // TABLE OF CONTENTS // ----------------------------------------------------------------------------- // 01. Enqueue Parent Stylesheet // 02. Additional Functions // ============================================================================= // Enqueue Parent Stylesheet // ============================================================================= add_filter( 'x_enqueue_parent_stylesheet', '__return_true' ); // Additional Functions // ============================================================================= function x_custom_blog($query) { if( !is_admin() && $query->is_main_query() ) { if( $query->is_home() ) { $query->set('post_type', array( 'post', ‚video‘ ) ); } } } add_action('pre_get_posts','x_custom_blog');
Let me know what to do next.
Thank you!!September 18, 2016 at 8:27 am #1180140This reply has been marked as private.September 18, 2016 at 9:04 am #1180163This reply has been marked as private.September 18, 2016 at 12:38 pm #1180307Thanks again! I included the video post type in the essential grid settings and corrected the code in the functions.php. But still no luck – the video post still doesn’t appear…
September 18, 2016 at 12:46 pm #1180309I do see the custum post on the X-Blog Index page (see link from erlier conversation). But it has a different layout than the other posts and shows no featured image. Anyway I do not want to use that index page, but maybe this can help you see why it does not show up on my Essential Grid index page…
Thanxx!!
September 18, 2016 at 12:49 pm #1180311That’s the recent post from custom post type “video” on the x blog index page…
September 18, 2016 at 5:36 pm #1180515Hi there,
You post types should also have featured image. In your Grid source, you only selected one category but didn’t select catgeory assigned to your video post type.
Try selecting the Vortrag too .
Thanks!
September 19, 2016 at 7:36 am #1181289This reply has been marked as private.September 19, 2016 at 10:17 am #1181556Hi there,
Editing EG settings will only affect your preferred EG at http://dev.2016.christianseidel.de/pinnwand. It’s not related to your blog index anymore. What I’m saying is, you have to set featured image since it’s also required under media sources setting of your EG. And category relation should be OR and not AND. I went ahead and changed it.
About the issue you’re getting from custom post type, you may contact the plugin author. I’m not really sure how their plugin works.
For the meantime, please delete your custom post type and add the new one. Maybe it’s the reason it’s not properly appearing and the setting is corrupted. Is supposed to be blank when editing (eg. no editor and no other controls)?
Thanks!
September 19, 2016 at 1:17 pm #1181862Thanks, I think it is fixed now! Deleting the custom post type and creating a new one helped!
Now the post is showing on my blog index page as well as the one from X.
Only thing left to fix is:
1. The post doesn’t show up in “recent post” on the sidbar or “recent post”-widget. Do you have an idea how to make that work?2. The layout of custum posts is different from the ones created with regular post type. The changes I made to the layout via apearance > customizer > css do not apply to the custom post. Can you tell me how to make them all look the same?
Thanks for your patience!!
September 19, 2016 at 9:37 pm #1182515Hi There,
1.) By default, custom post types is not available on Recent Post element. To include it, please check this thread:https://community.theme.co/forums/topic/recent-posts-widget-to-show-custom-post-types/
2.)Please update the following custom CSS:
.single-post.x-post-meta-disabled .post .entry-featured { margin-top: 0; } .single .hentry .entry-wrap { padding-top: 0; } /*Posttitel*/ .entry-title { text-align: left; } .single-post .entry-header { padding-top: 2em; margin: 0 auto; margin-bottom: -3em; padding-left: 10%; padding-right: 10%; } .single-post .entry-header .entry-title { width: 89% !important; padding: 0; max-width: 1200px; } @media(max-width: 770px){ .single-post .entry-header { padding-left: 0; padding-right: 0; margin-bottom: -2em; font-size: 130%; } }
To this:
.single-post.x-post-meta-disabled .post .entry-featured, .single-video_beitrag.x-post-meta-disabled .post .entry-featured { margin-top: 0; } .single .hentry .entry-wrap { padding-top: 0; } /*Posttitel*/ .entry-title { text-align: left; } .single-post .entry-header, .single-video_beitrag .entry-header{ padding-top: 2em; margin: 0 auto; margin-bottom: -3em; padding-left: 10%; padding-right: 10%; } .single-post .entry-header .entry-title, .single-video_beitrag .entry-header .entry-title{ width: 89% !important; padding: 0; max-width: 1200px; } @media(max-width: 770px){ .single-post .entry-header, .single-video_beitrag .entry-header { padding-left: 0; padding-right: 0; margin-bottom: -2em; font-size: 130%; } }
Hope this helps.
-
AuthorPosts