Q: Hi, So my theme does not have the functionality to display custom post types in the main recent queries and such.
Even if I register the category. Sad and unfortunate.
Does yt2posts use a custom post type or will it send over the info to the table as a normal post? Let me know, please.
CHF-TECH
May 14, 2024A: In that case, you can use the built-in shortcodes for displaying the posts in a grid
(https://yt2posts.com/docs/examples/showing-videos-in-a-grid-with-a-shortcode/)
or a slider(
https://yt2posts.com/docs/examples/showing-videos-in-a-slider-with-a-shortcode/)
YT2Posts also comes with a default single-post templates, so they will be used.
If you observe any problems, feel free to contact our support at info@chftech.net.
Yea, i absolutely must have the ability to do the single posts are we good here or are these custom post types?
What i mean they will show in a standard query for say new posts and such... you know like home page stuff and display as any other post would.
Thanks for your questions! Although we have already responded per email, we will also write the response here, in case somebody has similar questions.
If you would like your theme to treat youtube posts as regular posts, then you can just add the following code into the functions.php file of your theme:
function include_video_posts( $query ) {
if ( is_home() && $query->is_main_query() )
$query->set( 'post_type', array( 'post', 'yt2posts_youtube' ) );
return $query;
}
add_action( 'pre_get_posts', 'include_video_posts' );
This would automatically include the video posts into every main query of the theme. As you noted, it's better to add this code using the Code Snippets plugin, instead of directly modifying the theme's function.php file.
Alternatively, many themes like Astra, GeneratePress and similar, allow using shortcodes. In that case, you can insert the video posts by adding the shortcodes provided by YT2Posts:
- for a grid: https://yt2posts.com/docs/examples/showing-videos-in-a-grid-with-a-shortcode/
- for a slider: https://yt2posts.com/docs/examples/showing-videos-in-a-slider-with-a-shortcode/
If you are using page builders like Elementor, Brickbuilder, Divi Builder or similar, then you can design even more flexible templates, as we described here:
https://yt2posts.com/docs/designing_templates/the-overview-of-templates/
We hope this helps!