1

わかりました、私は私のクライアントのためにこれを実装する簡単な方法を高低で探していました。

これが私が達成しようとしていることです:http: //www.trails2000.org/site/trail_conditions.html

どうしたらいいのかわからない?簡単にテーブルを作成して更新させることができます。

または、GD Starの評価を見て、マルチセットを実行していましたか?しかし、それについてもわかりません。

私が見落としているものはありますか?

ありがとう!

4

4 に答える 4

3

このような状況では手動コーディングが最適であるため、必要な機能をより細かく制御できます。

投稿タイプを使用してこれを構築することを検討してください

   http://codex.wordpress.org/Post_Types

カスタム投稿タイプの詳細については、このスライドを確認してください

http://www.slideshare.net/williamsba/custom-post-types-and-taxonomies-in-wordpress
于 2012-07-05T04:36:45.290 に答える
2

手動で行わないでください(「手動で」収集するか、ハードコーディングを参照するか、ユーザーにWYSIWYGエディターを使用してテーブルを編集してもらいますか?)。

誰もが言っているように、それを習慣的にしてください。カスタム投稿タイプ、カスタム分類法、およびカスタムフィールドを使用する必要があります。

プラグインを使用する場合は、カスタム投稿タイプ、カスタム分類法、および次のようなカスタムフィールドを管理するプラグインを探す必要があります:http://magicfields.org/

そうは言っても、プラグインなしでそれを手動でコーディングすることはそれほど難しいことではなく、すべてがどのように組み合わされているかをよりよく理解できるはずです。

「トレイル」はカスタム投稿タイプである必要があります。「Trail」投稿タイプには、「Colorado Trail System」、「Fort Lewis TrailSystem」などを保持するカスタム分類「TrailSystem」が必要です。「Trail」投稿タイプには、「condition」および「condition」のカスタムフィールドが必要です。おそらく「コメント」。ただし、「コメント」は代わりに投稿本文に保存できます。

クライアントは、「投稿」と「カテゴリ」を追加するのと同じように、Wordpress管理インターフェースから「トレイル」と「トレイルシステム」を追加することで、サイト自体を更新できます。

わかる?

編集:以下は、生のコードを使用して上記を設定する方法を説明しています(つまり、プラグインなし)

以下は、functions.phpに含める必要のあるサンプルコードです。このコードがfunctions.phpに入ると、「Trails」がadmininteraceの「Posts」の下に表示されます。「TrailSystems」は、「Categories」が「Posts」に対して行うのと同じように、「Trails」のドロップダウンメニューに表示されます。新しい「Trail」を追加するときは、「comments」と「condition」のカスタムフィールドが下にあるはずです。

<?php 

// CREATE YOUR CUSTOM POST TYPE
add_action( 'init', 'create_custom_post_type_trail');
function create_custom_post_type_trail() {

    // Set all the labels for your custom post type, as they will appear in the wordpress admin interface.
    $labels = array( 
        'name' => _x( 'Trails', 'trail' ),
        'singular_name' => _x( 'Trail', 'trail' ),
        'add_new' => _x( 'Add New', 'trail' ),
        'add_new_item' => _x( 'Add New Trail', 'trail' ),
        'edit_item' => _x( 'Edit Trail', 'trail' ),
        'new_item' => _x( 'New Trail', 'trail' ),
        'view_item' => _x( 'View Trail', 'trail' ),
        'search_items' => _x( 'Search Trails', 'trail' ),
        'not_found' => _x( 'No Trails found', 'trail' ),
        'not_found_in_trash' => _x( 'No Trails found in Trash', 'trail' ),
        'parent_item_colon' => _x( 'Parent Trail:', 'trail' ),
        'menu_name' => _x( 'Trails', 'trail' ),
    );

    // Set all the options for your custom post type - you may need to change some of these
    $args = array( 
        'labels' => $labels,
        'hierarchical' => false,

        'supports' => array( 'title', 'editor', 'custom-fields' ),
        'taxonomies' => array(),
        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'menu_position' => 5,

        'show_in_nav_menus' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'has_archive' => true,
        'query_var' => true,
        'can_export' => true,
        'rewrite' => array('slug' => 'trails', 'with_front' => false),
        'capability_type' => 'post'
    );

    register_post_type( 'trail', $args );
}

// ADD CUSTOM FIELDS TO THE TRAIL CUSTOM POST TYPE
add_action('wp_insert_post', 'add_custom_trail_fields');

function add_custom_trail_fields($post_id) {
    if ( isset($_GET['post_type']) and $_GET['post_type'] == 'trail' ) {
        add_post_meta($post_id, 'condition', '', true);
        add_post_meta($post_id, 'comments', '', true);
    }
    return true;
}

// ADD CUSTOM TAXONOMY TO THE TRAIL CUSTOM POST TYPE
add_action( 'init', 'create_trail_taxonomies' );
function create_trail_taxonomies(){

    // Set all the labels for your custom taxonomy, as they will appear in the wordpress admin interface.
    $labels = array(
        'name' => _x( 'Trail Systems', 'taxonomy general name' ),
        'singular_name' => _x( 'Trail System', 'taxonomy singular name' ),
        'search_items' =>  __( 'Search Member Categories' ),
        'all_items' => __( 'All Member Categories' ),
        'parent_item' => __( 'Parent Trail System' ),
        'parent_item_colon' => __( 'Parent Trail System:' ),
        'edit_item' => __( 'Edit Trail System' ), 
        'update_item' => __( 'Update Trail System' ),
        'add_new_item' => __( 'Add New Trail System' ),
        'new_item_name' => __( 'New Trail System Name' ),
        'menu_name' => __( 'Trail System' ),
    ); 

    // Set all the options for your custom taxonomy - you may need to change some of these
    $args = array(
        'labels' => $labels,
        'label'=>'Trail Systems',
        'hierarchical'=>true, // this makes them behave like 'categories' as opposed to like 'tags'
        'rewrite' => array('slug' => 'trail_system', 'with_front' => false),
    );
    register_taxonomy('trail_system', 'trail', $args);

}

/*
// This is for if you make a mistake, and have to unregister a taxonomy and register it with a new name
add_action( 'init', 'unregister_taxonomy');
function unregister_taxonomy(){
    global $wp_taxonomies;
    $taxonomy = 'XXXXXXXXX'; // name of your taxonomy goes here.
    if ( taxonomy_exists( $taxonomy))
        unset( $wp_taxonomies[$taxonomy]);
}
*/


?>

あなたが役に立つと思うかもしれない他のいくつかのもの:

パーマリンクの設定方法に応じて、http://www.example.com/ ?post_type=trailやhttp://www.example.com/trailなどのURLでトレイルにアクセスします。

テーマでは、アーカイブ/単一の「Trail」投稿用のカスタムテンプレートを作成するためのファイルarchive-trail.phpおよびsingle-trail.phpを作成できます。

The Loop内では、次のようなカスタム投稿フィールドにアクセスできます。

<?php
$fields = get_post_meta( get_the_ID()); // get all custom fields
echo $fields['comments'][0]; // display 'comments' field
echo $fields['condition'][0]; // display 'condition' field
?>

また、The Loop内で、次のようなカスタム分類法を取得します。

<?php 
$trail_system = get_the_terms( $post->ID, 'trail_system');
echo $trail_system;
?>

最後に、Trailsの検索で何かを行う必要があるかどうかはわかりませんが、必要な場合は、http://thereforei.am/2011/10/28/advanced-taxonomy-queries-with-pretty-urlsを確認してください。 //

于 2012-07-05T05:33:55.120 に答える
1

私の経験では、カスタムの方がはるかに優れており、柔軟性が向上しています。プラグインを使用したことが何度もありました。最初は時間を節約できたからです。その後、プロジェクトの 70% でいくつかの小さな変更を加える必要がありました。その結果、どこでどのように作成するかを理解するために、より多くの時間を浪費することになりました。私が自分で全部をコード化できたはずの変更。

于 2012-07-05T03:02:34.097 に答える
0

編集者以上のユーザーが更新できるように、各トレイルの変数を具体的に保存する管理ページを作成できます (「良い」「悪い」など)。確かに、ここでのカスタム ソリューションが最適だと思います。

http://myego.orgにログインしてから「My EGO」ページに移動すると、そのような管理ページが表示されます (ただし、これはすべてフィールドですが、あなたのページはすべてドロップダウン メニューです)。

于 2012-07-05T04:18:13.380 に答える