これは、スタック オーバーフローに関する私の最初の投稿です。
私は WordPress の初心者で、基本的なプロパティ リストを使用する最初のテーマの開発をほぼ完了しました。
ここで確認して、この問題を解決しようとしました..
- http://codex.wordpress.org/Function_Reference/register_taxonomy
- http://codex.wordpress.org/Function_Reference/query_posts
..多くの Google 検索と同様に。そして、私を助けるものを見つけることができないようです。
「tfg-properties」と呼ばれるカスタム投稿タイプからの投稿を、必要な順序で表示するのに問題があります。
カスタム分類 - 'featured-properties' - functions.php
register_taxonomy('featured-properties', 'tfg-properties', array(
"hierarchical" => true,
"label" => "Featured Properties",
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array(
'slug' => 'featured-property',
'with_front' => false ),
'public' => true,
'show_ui' => true,
'show_tagcloud' => true,
'_builtin' => false,
'show_in_nav_menus' => false)
);
この投稿タイプの「featured-properties」と呼ばれるカスタム分類法を作成しました。私がやりたいことは、分類法の「featured-properties」からの投稿を他の投稿の前に表示することです。
カテゴリを使用してこれを達成できますが、ブログも組み込んでいるため、これは機能しません..
これが私の投稿を照会する方法です..
カテゴリ ID で投稿をクエリする - page.php
// Get all posts from featured properties
$catId = get_cat_ID('Featured Property');
query_posts('post_type=tfg-properties&cat=' . $catId);
// begin the loop
while( have_posts() ): the_post(); ?>
<li class="single-prop">
...
</li>
<?php endwhile; ?>
// Get all posts from featured properties
query_posts('post_type=tfg-properties&cat=-' . $catId);
// begin the loop
while( have_posts() ): the_post(); ?>
<li class="single-prop">
...
</li>
<?php endwhile; ?>
カスタム投稿をカスタム税で並べ替えて、他の投稿の前に表示する方法はありますか?
前もって感謝します!