WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Select category for post in a custom publishing post page (5 posts)

  1. jetonr
    Member
    Posted 4 years ago #

    Hello,
    I created a page in wp admin to quickly publish videos, but i need to select a video category for that video and this is what i did so far but it doesnt work for me. I hope somebody can help me.

    $my_post['post_category'] = $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>
  2. sojweb
    Member
    Posted 4 years ago #

    What is not working about it?

  3. jetonr
    Member
    Posted 4 years ago #

    Bump: anybody please...

  4. jetonr
    Member
    Posted 4 years ago #

    Well I can select a categoory for the post but I will show uncategorised allthough i can select the category from the drop down list. This is a custom page that I made for publishing, cant getthe categories to work.
    here is how i strucured it.

    // 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>
  5. sojweb
    Member
    Posted 4 years ago #

    I still don't quite understand what you're doing... and parts of your code don't make sense. Where is the $row array coming from, and what are you doing with $my_post? What does the selected() function do? (It looks like it's trying to mark the selected option, but that won't work because the <option> tag is closed in the line above it.) And why are you using the ucfirst() function? It won't do anything because the first character of $video_category is non-alphabetic.

Topic Closed

This topic has been closed to new replies.

About this Topic