0
votes

I am working with several Custom Fields which are "allocated" to Custom Post Types. For some odd reason one Custom Field needs to be created over and over again. I cannot seem to find a solution that this specific Custom Field is saved onto my Wordpress Database for future use.

The Custom Field is called "video_url". Even if I rename it so "youtubelink" or whatsoever Wordpress does not save it. Any other newly created Custom Fields are saved by Wordpress but not that one that must hold the Youtube Link.

Any ideas? Is there something to "force" WP to keep that Custom Field?

NB: I am not using any Plugins to create Custom Fields.

2
Are you saving the custom field with php ? Can you provide us your code ? - Alexis Vandepitte
Here's how I call the results for the specific Custom Post Type ''<?php if (!((get_post_meta($post->ID, 'video_url', TRUE))=='')) { echo wp_oembed_get( get_post_meta($post->ID, "video_url", true) ); }?>'' I basically want to display the embedded Youtube video - mad2kx

2 Answers

0
votes

I think you need use a php function to update or execute this sql in phpmyadmin

update `<your_prefix>_postmeta` pm set pm.meta_key = 'youtubelink' where  pm.meta_key = 'video_url'

If you use $wpdb you can add this code to function.php in your theme

global $wpdb;
 echo $sql = "update `{$wpdb->prefix}postmeta` pm set pm.meta_key = 'youtubelink' where  pm.meta_key = 'video_url'";
$wpdb->query($sql);
exit;

i added exit to make sure this code is executed. You reload page to run this script and then comment them to check. If nothing updated you use this code

global $wpdb,$prefix;
     echo $sql = "update `{$prefix}postmeta` pm set pm.meta_key = 'youtubelink' where  pm.meta_key = 'video_url'";
    $wpdb->query($sql);
    exit;

this is code used in old wordpress version. You reload page to run script, comment code to check again...

0
votes

I solved this problem by increasing the Post Meta in my functions.php

Looks like Wordpress has a postmeta limit @ 30. With the function below you can increase it to higher values.

Works like a boss

/* Increase Postmeta Limit.*/

add_filter( 'postmeta_form_limit', function( $limit ) {
    return 100;
} );