Support » Plugin: Automatic Featured Images from Videos » Use plugin on pages

  • Resolved rebah



    Thanks for a great plugin! I would like to use it on pages though. My theme comes with a portfolio option, which I believe are pages. Is it possible to make a slight adjustment to the code so it also, or only works on pages?


Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Michael Beckwith


    The BenchPresser

    Should already work on pages/custom post types. The biggest question I’d end up having is if this theme uses the standard post editor content field, or if it’s setting up custom meta boxes for the place you’ve perhaps been testing with.

    The plugin searches the post content field by default, but it can be filtered to search for a user-provided spot in replacement.

    Thread Starter rebah


    Hey Michael,

    Thank for your reply. I’m pretty sure they are custom boxes. But if I understand you correctly, it is possible? If I use developer tools and click on the field where i need to place the embed code in the pages admin area it says textarea#tz_video_embed . Is there anything I can do with this info to make it work?

    Plugin Author Michael Beckwith


    The BenchPresser

    Yes, I don’t see why it wouldn’t be possible. You’ll still need to use the filter highlighted above, but note that some spots in that link are updated recently and not matching what’s in the released version on here.

    Chances are the video URL is being stored in post meta for the post(s) in question. Just a matter of figuring out which one. Once you know the meta_key for it, you’ll need to use the filter and return the meta_value for that custom field. By default the filter has a chunk of the post_content that it searches for URLs for. You’ll need to return an alternative value to the filter for the plugin to search through instead.

    Admittedly, the filter, as is, won’t be great for initial views of the post editor, when there’s no post ID displayed in the URL. Once there is though, you should be able to grab that ID value via the $_GET global and use it to query for the custom field value inside your callback to the filter. I want to get this changed in a future release of the plugin.

    Rough example code:

    function filter_the_searched_content( $content ) {
        if ( ! empty( $_GET ) && isset( $_GET['post'] ) ) {
            // We have an ID. Let's check for a saved meta value.
            $meta = get_post_meta( 'my_meta_key', absint( $_GET['post'] ), true );
            if ( ! empty( $meta ) ) {
                // We have saved meta data! Let's return that to the filter so Auto Featured Images searches for a url there.
                return $meta;
        // We either didn't have an ID, or we didn't have meta content saved, so let's just return the original value.
        return $content;
    add_filter( 'wds_featured_images_from_video_filter_content', 'filter_the_searched_content' );
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Use plugin on pages’ is closed to new replies.