0

EDITED:

I'm trying to create a post when I submit my form from my custom themes page on the backend

function simplyme_portfolio_icon_1() {
    $options = get_option( 'simplyme_theme_portfolio_options', false );

    if( isset( $options['portfolio_icon_1'] ) ) {
        $icon = ( $options['portfolio_icon_1'] );
    }

  $dir = get_template_directory() . '/' . $icon;
  if ( ! is_dir( $dir ) ) {wp_mkdir_p( $dir );}

  $post_id = wp_insert_post( array(
    'post_title'    =>    $icon,
    'post_status'   =>    'publish',
    'post_author'   =>    1,
    'post_type'     =>    'portfolio',
  ) );

    echo '<input type="text" id="portfolio_icon_1" name="simplyme_theme_portfolio_options[portfolio_icon_1]" value="'.$icon.'" />';
} // end simplyme_portfolio_icon_1
add_action( 'admin_iniit', 'simplyme_portfolio_icon_1' );

Now it does create the post but also creates a (no title) post as well did I do something?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.