Answer the question
In order to leave comments, you need to log in
How to make video in wordpress post preview?
Here is a site , instead of a preview of the picture, I want to display the video from the post on the main page, please give me ideas on how to do this.
Answer the question
In order to leave comments, you need to log in
1. Find a homepage template. front-page.php or home.php, or at least index.php. Template Hierarchy to the rescue.
2. In the template, find where the records you need are displayed. There is either a ready-made piece of code in a loop, or connecting a template part with the necessary code.
3. Instead of get_post_thumbnail you will need to insert your custom function that will display the video.
4. It remains to write this function. She should take a post, regularly look for a video and take its code.
1. Create a field for your records. It is possible through ACF (text field).
2. Create a function in functions.php to get an iframe from the given field. I think you can just the_field ()
3. Create a class in your .css to compress the size of the iframe to the desired screens, etc. With the_field() wrapper, and css class .your {code etc, width:50%;height:auto; etc}
2. When displaying information on the desired page, you - do instead of the_post_thumbnail() your created function with your classes that you created in the .css file.
You can use my plugin to create post type links.
https://ru.wordpress.org/plugins/npc-neatekpostconnect/ Plugin
scheme:
1. Create 2 post types.
2. Connect through the plugin, instructions on the plugin page.
3. Write a function to display the_content() of the associated post types for your post to be displayed. Examples are also on the plugin page.
4. Rejoice.
With the plugin, of course, it turns out to be much more flexible, and there you can already bind anything to anything, and display information attached to your posts from other posts. As if it is "Video", "Photo", "Album", "Maps" and so on.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question