admin管理员组文章数量:1335607
I'm very new to Wordpress, so apologies. I have a project that I'm working on and I'm hoping someone could point me in the right direction.
To start off I am volunteering to do some work for a small non-profit organization in my town that organizes community events. They wanted to create a video player on their website where they can showcase videos about what they're doing. They don't want to embed youtube videos to avoid sending traffic off to youtube, because the ultimate goal is to get people to subscribe to an email list and or donate.
My initial plan of attack was to create a page that with an html5 video player and a watch next panel with thumbnails that link a similar page with the next video.
I had two problems to address: (1) I wanted to have just one page, so that it could be very easily updated. (2) I needed to have unique links for each video, so that they could be shared.
My original solution was to use query strings in the url to find the path to fill in the page for each video (find the file path of the video and the videos to watch next in a database table by associating it with a query string variable).
It was at this point that I was told that the website was a wordpress site. I can build the basic page for any specific video in wordpress, but I'm really at a loss for how to handle the query strings). I have tried to do a little research-- which resulted in me attempting to build a child theme and add some code to the functions.php file, but the issue I keep running into is that I have no idea how to add a table for my videos to the database and I can't manage to do this the way I had planned without some kind of database.
It's probably clear that I have no idea what I'm talking about and I'm pretty sure that there's a much better way to design this whole thing. I was hoping for some suggestions about the best way to handle the problems I wanted to solve: (1) easy to update and add new videos to and (2) has unique urls for sharing.
I'm very new to Wordpress, so apologies. I have a project that I'm working on and I'm hoping someone could point me in the right direction.
To start off I am volunteering to do some work for a small non-profit organization in my town that organizes community events. They wanted to create a video player on their website where they can showcase videos about what they're doing. They don't want to embed youtube videos to avoid sending traffic off to youtube, because the ultimate goal is to get people to subscribe to an email list and or donate.
My initial plan of attack was to create a page that with an html5 video player and a watch next panel with thumbnails that link a similar page with the next video.
I had two problems to address: (1) I wanted to have just one page, so that it could be very easily updated. (2) I needed to have unique links for each video, so that they could be shared.
My original solution was to use query strings in the url to find the path to fill in the page for each video (find the file path of the video and the videos to watch next in a database table by associating it with a query string variable).
It was at this point that I was told that the website was a wordpress site. I can build the basic page for any specific video in wordpress, but I'm really at a loss for how to handle the query strings). I have tried to do a little research-- which resulted in me attempting to build a child theme and add some code to the functions.php file, but the issue I keep running into is that I have no idea how to add a table for my videos to the database and I can't manage to do this the way I had planned without some kind of database.
It's probably clear that I have no idea what I'm talking about and I'm pretty sure that there's a much better way to design this whole thing. I was hoping for some suggestions about the best way to handle the problems I wanted to solve: (1) easy to update and add new videos to and (2) has unique urls for sharing.
Share Improve this question asked May 29, 2020 at 5:08 BrunoBruno 111 bronze badge 1- I should have been more clear: they already have wordpress website. This would be like another page on the wordpress website. – Bruno Commented May 29, 2020 at 5:11
1 Answer
Reset to default 1Welcome to WPSE. There's probably more than one way to do this, but here's my first thoughts.
The first thing you may want to do is to register a custom post type (CPT) for the video content. This way you can have "video library" at the backend (i.e. Dashboard) for managing the video content.
If you don't need to add long text content to be shown along the video, you can set the CPT support arguments as title, excerpt, and thumbnail. To disable block editor for the CPT set 'show_in_rest'=>false
. To store the video url you can register a custom meta box. Storing meta data with block editor requires a bit more involvement, if you decide to use it.
To display the videos on the frontend you can either set the CPT to visibility argument 'public'=>true
and create custom single template or make the CPT private ('public'=>false
) and create a custom page template where you display videos by getting the id from a query string (i.e. $video_id = $_GET['video_id']
). You may want to familiarize yourself with the concept of the Loop, if you haven't already, regardless which template type you use.
If your CPT is public, you use a custom single template, and you've stored the video url to post meta, then you can retrieve it in the template file with get_post_meta(). WP takes care of creating shareable permalink for the video post.
If your CPT is private, then you could store the video id to the custom post's slug field (post_name
) and video url to post meta. In your custom page template you could then first use get_page_by_path() (works for CPT's too) with the video id from query string to get the post ID to be used with get_post_meta() to eventually get the video url. Another option is to use WP_Query with 'name'=>$video_id with 'fields'=>'ids' to query the post ID.
本文标签: databaseCreating a Video Content Page (how to use query strings in wordpress) Help
版权声明:本文标题:database - Creating a Video Content Page (how to use query strings in wordpress)- Help! 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742391358a2466054.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论