Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8383947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:17:44+00:00 2026-06-09T17:17:44+00:00

In WordPress, I have a custom post-type videos. Now on the edit (regular) posts

  • 0

In WordPress, I have a custom post-type “videos”. Now on the edit (regular) posts page, I would like to have a field “featured video” that allows me to select a video from all the videos of the custom post-type “videos”.

Where do I start?

PS: No plug-ins, please.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:17:45+00:00Added an answer on June 9, 2026 at 5:17 pm

    Easy Way:

    Create a Custom Field (enable Custom Fields by clicking Screen Options in the upper right-hand corner of your edit page) and call it “featuredVideo” with a value of the ID of the video you want to link to.

    Then call in your single post template like so:

    <?php
    $fvID = get_post_meta(get_the_ID(), 'featuredVideo', true);
    ?>
    <a href="<?php echo get_permalink($fvID); ?>">Check out the Featured Video!</a>
    

    Best Way:

    You can Add A Meta Box to your post editor with a simple dropdown to select from all Posts of type Video. This will require a decent chunk of code in your functions.php, and you will still need to store the information as metadata, but it gives you a clean interface to work with, and you no longer have to keep track of IDs to make it work.

    functions.php –

    add_action('add_meta_boxes', 'add_featured_video_meta');
    add_action('save_post', 'save_featured_data');
    
    function add_featured_video_meta()
    {
        add_meta_box( 
            'featured_video_meta',
            'Add Featured Video',
            'featured_video_inner',
            'post',
            'side'
        );
    }
    
    function featured_video_inner($post)
    {
        wp_nonce_field(basename(__FILE__), 'featured_video_nonce');
        $q = new WP_Query(array('post_type'=>'video', 'posts_per_page'=>-1));
    ?>
        <label for="featuredVideo">Select a Video: </label>
        <select name="featuredVideo">
        <option value="0">Select a Video</option>
    <?php
        if($q->have_posts()) : while($q->have_posts()) : $q->the_post();
            $selected = get_post_meta($post->ID, 'featuredVideo', true) === get_the_ID() ? ' selected="selected"' : '';
            echo '<option value="'.get_the_ID().'"'.$selected.'>'.get_the_title().'</option>';
        endwhile;endif;
    ?>
        </select>
    <?php
    }
    
    function save_featured_data($post_id)
    {
        if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) 
            return;
        if(!wp_verify_nonce($_POST['featured_video_nonce'], basename(__FILE__)))
            return;
        if(!current_user_can('edit_post', $post_id))
            return;
    
        update_post_meta($post_id, 'featuredVideo', $_POST['featuredVideo']);
    }
    

    The above example is untested, so I can’t guarantee it will work straight out of the gate, but the hard part is essentially done for you if that’s the approach you want to take. Once you get your custom Meta Box working, you can reference the post metadata in your single post template in exactly the same fashion I used in the first example.

    Just play around with it, and see what works best for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom posttype in Wordpress 3. I would like to every post
I have created a wordpress custom post type. I am using custom field template
I have a small problem on a wordpress custom post type page, whereby the
I have setup a custom Post Type in WordPress and have a question. How
I have setup a custom post type in Wordpress. It is a section where
I'm currently studying WordPress and want to create a custom Post Type and have
I have a custom post type of Products in my WordPress project. The CPT
I have a similar problem with this ( https://wordpress.stackexchange.com/questions/9593/custom-post-type-archive-with-pagination ) and can't really figure
I have a WordPress custom post-type setup. I've created single-[customposttype].php However instead of displaying
I have a Custom Post Type, 'ioni_codex' I am using built-in Wordpress category as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.