Support » Fixing WordPress » custom post and custom fields
4 years, 5 months ago
I have been trying to run a function from the functions.php file whenever a post is created of my custom post type.
This is the code that i am adding to my function.php file but it doesn’t seem to create the two custom fields s and l when a post is published.
$args = array( 'post_type' => 'sol');
$postslist = get_posts( $args );
foreach ($postslist as $post) :
add_post_meta(get_the_ID(), 's', 0, true);
add_post_meta(get_the_ID(), 'l', 0, true);
can someone advise what i am doing wrong here.
thanks in advance