Announcement

Collapse
No announcement yet.

How would I replace the post featured image with a featured video?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How would I replace the post featured image with a featured video?

    I have enabled featured images to display on posts via the following inserted into the custom functions editor:

    PHP Code:
    // Display Featured Image on top of the post
     
    add_action'genesis_before_entry''featured_post_image');
     function 
    featured_post_image() {
       if ( ! 
    is_singular'post' ) )  return;
         
    the_post_thumbnail('post-image');
     } 

    How would I enable the ability to replace the featured image with a featured video?

    Thanks!

  • #2
    Where does the featured video come from? A plugin?

    Comment


    • #3
      Originally posted by SiGa View Post
      Where does the featured video come from? A plugin?
      That was my question too!
      Off hand the Dynamik way of doing this would be to create a Custom Field, say called featured_video

      Then build on the conditional above to query if the custom field exist output the video.

      Comment


      • #4
        Using the Genesis Featured Video plugin unless there's a consensus on a better method:
        https://wordpress.org/plugins/featur...s-for-genesis/

        I feel like the knowledge base has me pointed in the right direction, just trying to wrap my mind around it: http://dynamikdocs.cobaltapps.com/ar...-post-elements

        Graphic designer masquerading as a developer, forgive me.

        Comment


        • #5
          Sorry, just trying to understand your question.

          But on the plugin page, it says (for archives):

          On the post edit page, there are two areas for you to look for. The first is titled “Format”. The second is titled “Genesis Featured Video”.

          On each post that you want to display a featured video on the archive page select “Video” from the Format section, and paste the URL to a video in the Genesis Featured Video section. Update or publish your post, and you should see your video replace the featured image on your blog or archive page.
          and (for single posts)
          You can embed the video the same way that you normally embed videos in a post, or you can use a small line of code to force your video to show up on the post page.
          add_action( 'pre_get_posts', 'add_video_to_posts', 1 ); function add_video_to_posts() { remove_action( 'pre_get_posts', 'gfv_hide_video_on_post', 10 ) ; }
          https://wordpress.org/plugins/featur...s-for-genesis/

          So none of this meets your requirements? And are we talking about normal WP posts or some custom post type?
          Last edited by SiGa; 05-10-2017, 02:15 PM.

          Comment


          • #6
            SiGa-

            I currently have Wordpress Post Formats enabled. I would like to be able to replace the featured image with a featured video if the video post type is selected. I currently have featured images enabled via the code below inserted into the Dynamik custom functions screen:

            PHP Code:
            add_action'genesis_before_entry''featured_post_image');
            function 
            featured_post_image() {
            if ( ! 
            is_singular'post' ) )  return;
            the_post_thumbnail('post-image');


            Then I also have the action you quoted added to the custom functions.

            PHP Code:
            add_action'pre_get_posts''add_video_to_posts');
            function 
            add_video_to_posts() { remove_action'pre_get_posts''gfv_hide_video_on_post'10 ) ;


            With that configuration, a sample video format post displays the custom image, followed by the title and post author, then the video inserted into the featured video plugin post field.

            That probably makes sense, but I'm not sure how to alter it to behave as desired. I assume it has to be along the lines of what Sogwap was referring to and I need to just fiddle around with it.

            Comment


            • #7
              Sadly I´ll have to talk pure theory here as we
              a) Don´t have anything to look at and as
              b) I don´t have such a setup available and couldn´t create one right now just to test the code involved. Sorry.

              https://codex.wordpress.org/Post_Formats

              I´d guess you´d have to alter the third line in the first snippet to include PHP saying "also return if the post format is video" to remove the featured image from those posts (conditionals see link above).
              Then it would only be a question of moving the video up above the title. Maybe the support forum of the plugin could give you a better hint for that?

              Comment


              • #8
                There was a snippet in a plugin support thread that solved my issue. Should have spent more time trying to resolve it myself but I really appreciate your time SiGa! Cheers!

                Comment

              Working...
              X