• Hi to everyone!

    I’m currently doing a migration from an old theme to a new theme, and I’m in a big trouble.

    My old theme (Newspaper from tagdiv) has a field with a Video option for the posts. When I put a video URL, the video shows at the begining of the post (magic!)

    Now, I want to migrate this video field to my new theme. For do that, first I have done a custom field on my new theme for insert the Video URL and show it on the posts. (and it works!)

    But my big trouble and the only problem that I have is when I try to export this field with WP All Export -Import plugin. I have this on MySQL Database “wp_postmeta“‘s table:

    INSERT INTOwp_postmeta(meta_id,post_id,meta_key,meta_value`) VALUES
    (213286, 18405, ‘td_post_video’, ‘a:1:{s:8:”td_video”;s:27:”https://vimeo.com/273779372″;}’),`

    How the hell I can “extract” the Vimeo URL and POst ID to do later the import to my new Video field on my new theme ??? I think this is an array or something else. I study MySQL, but this escapes my knowledge. Crazy!

    Thank you very much in advance.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 16 through 21 (of 21 total)
  • OK, add a line <pre><?php print_r($video) ?></pre> after the line with my_get_video_embed to see what the result looks like.

    We’ve got to match the expectation of wp_oembed_get (an URL string/text) with the result of the my_get_video_embed function call.

    We’re close ??

    Thread Starter Jordi

    (@kukat)

    On the admin side I get this error :
    ” Warning: htmlspecialchars() expects parameter 1 to be string, array given in /usr/home/diania.tv/web/wp-content/themes/mts_newspaper/functions.php on line 2525 Vídeo ”

    Thread Starter Jordi

    (@kukat)

    I get this:

    Array
    (
    [td_video] => https://vimeo.com/145711577
    )

    Thread Starter Jordi

    (@kukat)

    mmm…it’s very strange.
    In some videos, there are 2 fields:

    Array
    (
    [td_video] => https://youtu.be/jaJ89fnaktM
    [td_last_video] => https://youtu.be/jaJ89fnaktM
    )

    I think is a bad implementation of the theme xD

    • This reply was modified 4 years, 10 months ago by Jordi.
    • This reply was modified 4 years, 10 months ago by Jordi.

    This could be simplified if I were more hands-on, but here’s an update to the function:

    function my_get_video_embed($id) {
        $video = get_post_meta($id, 'video', true);
    
        if (empty($video)) {
            $video = get_post_meta($id, 'td_post_video', true);
    
            if (!empty($video) && !empty($video['td_video'])) {
                $video = $video['td_video'];
                update_post_meta($id, 'video', $video);
            }
        }
    
        if (!empty($video) && is_array($video) && !empty($video['td_video'])) {
            return $video['td_video'];
        }
    
        return $video;
    }
    
    Thread Starter Jordi

    (@kukat)

    Oh yes!!!
    Thank you very very much!!!
    Now i have all the videos enabled on the site!
    Have a nice friday and a great weekend!

Viewing 6 replies - 16 through 21 (of 21 total)
  • The topic ‘Extract a field from an array on MySQL DB on WordPress’ is closed to new replies.