質問

3つのカスタムポストタイプがあり、それぞれ約5つの分類法と2つのカスタムポストタイプが2つの分類法を共有しています。

Post_typesを表示するためにドロップダウンの部分以外のフロントエンドから投稿するためにすべてを設定したばかりです。

現在はフロントエンドの投稿が機能しているため、URLはカスタムポストタイプが含まれていないために壊れています。カスタムポストタイプのリストでゼロを見つけることができます...実行できますか?

よろしくマーティン

編集:これにつまずいただけです Codexで,,

役に立ちましたか?

解決

申し訳ありませんが、自分の質問に少し奇妙に答えていますが、ここに行きます。

最初に変数を宣言します:( customcategory)

global $userdata;

$errors = array();

$title      = trim($_POST['wpuf_post_title']);
$customcategory      = trim($_POST['customcategory']);
$content    = trim($_POST['wpuf_post_content']);
$tags       = wpuf_clean_tags($_POST['wpuf_post_tags']);
$cat        = trim($_POST['cat']);

第二に、投稿を追加するための配列:

 if (!$errors) {
    $frontend_post = array(
            'post_title'    => $title,
            'post_content'  => $content,
            'post_status'   => $post_status,
            'post_author'   => $userdata->ID,
            'post_category'    =>    array($_POST['cat']),
            'post_type' => $customcategory,
            'tags_input'    => $tags
    );

    $post_id = wp_insert_post($frontend_post);

そして最後に、get_post_types関数から排水を作成します。

<?php 
          $args=array(
                     'public'   => true,
                     '_builtin' => false
                     ); 
                $output = 'names';
                $operator = 'and';
                $post_types=get_post_types($args,$output,$operator); 

          echo '<select name="customcategory">';
          foreach ($post_types  as $post_type ) {
          echo '<option value="'. $post_type.'">'. $post_type. '</option>';
}echo '</select>';
?>
ライセンス: CC-BY-SA帰属
所属していません wordpress.stackexchange
scroll top