WP User Frontend
Set post_format when adding post? (3 posts)

  1. absurdo
    Posted 4 years ago #

    Is it possible to set post_format when adding post?


  2. adaldesign
    Posted 3 years ago #

  3. adaldesign
    Posted 3 years ago #

    I was finally able to create a drop down to set post format using the hooks provided by Tareq and wanted to share my code in case it can be of use to anyone.

    Paste the following in your functions.php

    // Add the drop-down (you can edit the list of post format options)
    function wpufe_content_type( $post_type, $post = null) {
            <label for="post_format">Content Type<span class="required">*</span></label>
            <select class="requiredField" name="content_type" id="content_type">
            	<option value="" selected="selected">What are you posting?</option>
                <option value="standard">Text (Blog Post)</option>
                <option value="image">Single Image</option>
                <option value="gallery">Gallery of Images</option>
                <option value="video">Video</option>
                <option value="audio">Audio</option>
            <div class="clear"></div>
    add_action( 'wpuf_add_post_form_top', 'wpufe_content_type', 10, 2 );
    // Validate the data (optional)
    function wpufe_content_type_validation( $errors ) {
        if( $_POST['content_type'] == '' ) {
            $errors[] = 'Please select a Content Type.';
        return $errors;
    add_filter( 'wpuf_add_post_validation', 'wpufe_content_type_validation' );
    // Make it happen!
    function wpufe_add_content_type( $post_id ) {
    	set_post_format( $post_id, $_POST['content_type'] );
    add_action( 'wpuf_add_post_after_insert', 'wpufe_add_content_type' );

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP User Frontend
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic