WordPress.org

Forums

[resolved] Post publishing category select ( custom made page ) (1 post)

  1. jetonr
    Member
    Posted 6 years ago #

    Hope somebody can help me solve this, I am struggling for more than 2 days. I have a custom post publishing page and I want to select categories for the post from categories dropdown, and use the value selected. I don't know what im doing wrong but cant get it to work. It allways publishes the post with uncategorised. Here is the code.

    // Category exists?
    if (!empty($_POST['video_category'])) {
    $video_category = $_POST['video_category'];
    } else {
    $video_category = 'Please select a category';
    }
    
    $my_post['post_category'] = array(prep($row['video_category'])); 
    
    <select name="video_category" class="widefat mid">
     <option value="video_category">Select Category...</option>
     <?php
      $categories=  get_categories('');
      foreach ($categories as $videocategory) {
      	$video_category = '<option value="/category/archives/'.$videocategory->category_nicename.'">';
    	$video_category .= $videocategory->cat_name;
    	$video_category .= selected($videocategory, $_POST['video_category']);
    	$video_category .= '</option>';
    	print ucfirst($video_category);
      }
     ?>
    </select>

Topic Closed

This topic has been closed to new replies.

About this Topic