0
페이지의 이름을 공유하는 범주의 게시물을 나열하려고합니다. 나는. "서비스"페이지에있는 경우 "서비스"범주의 게시물을 표시해야합니다. 나는 다음과 같은 조건문과 함께 할 쉽게 실현 :페이지 제목과 일치하는 카테고리로 단어 목록을 나열하십시오.
<?php if ((is_page('Groups'))) { query_posts('category_name=groups');
while (have_posts()) { the_post();?>
<h2 class="title" id="sub">Upcoming Group Programs</h2>
<a href="<?php the_permalink() ?>">
<div class="post" id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2></a>
<div class="entry"><?php the_content(); ?></div>
</div>
<?php } wp_reset_query(); //Restores Global Post Data }?>
하지만 뭔가 같은 여러 특정 조건문을 설정하지 않고이 작업을 수행하고 싶습니다 :
<?php //global $wp_query; // Uncomment if necessary, shouldn't be
$test = the_title();
$args = array('cat_name' => $test // ARGS HERE);
$args = array_merge($args , $wp_query->query);
query_posts($args); while (have_posts()) { the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<div class="entry"><?php the_content(); ?></div></div>
<?php } ?>
어떤 생각을! 분명히 페이지 & 카테고리 "이름"을 "슬러그"또는 가장 잘 작동하는 것으로 교환 할 수 있습니다. 감사!
감사합니다. 나는 주변에 몇 가지를 바꿨고 당신의 제안과 함께 작동하게했다.
다행스럽게도 필자가 올바르게 연결했다가 마지막 줄에<?php
$catmatch = get_the_title();
//The Query
query_posts('category_name=' . $catmatch); ?>
, 작동하는 것 같다하지만이 아닌 경우는 제대로 알려 주시기 바랍니다하도록되어 방법!