Support » Fixing WordPress » Error Handing with post meta

  • I’m having trouble adding some custom error handling for my custom meta fields. Basically I just want to check to see if an item has been selected from the drop down. If not then return an error code. Here is the snippet of code that I have added to the wp_insert_post function in “wp-includes/post.php

    $topic = get_post_meta($post->ID, 'Topic :', true);
    	$source = get_post_meta($post->ID, 'Source :', true);
    	if ('' == $topic || '' == $source ) {
    		return selecterror;

    Currently, the topic and source variables are return nothing hence the reason why the if statement is always correct. I not sure if this code is in the best spot. Any help on this would be great or perhaps the best place to add custom error handling on a submit.

  • The topic ‘Error Handing with post meta’ is closed to new replies.