1

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 should have been more clear: they already have wordpress website. This would be like another page on the wordpress website. – Bruno May 29 at 5:11
1

Welcome 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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.