좋아, 내가 씨름하고있는 또 다른 코드가있다. 조건부 사이드 바를 만들고 있습니다. 목표는 "블로그"카테고리의 게시물을 볼 때 블로그 관련 항목 만 표시하는 것입니다. 그 중 일부는 작동하지만, 최근 게시물로 표시하기 위해 카테고리의 RSS 피드를 사이드 바에 가져 오려고하는 부분입니다. 그것은 작동하지 않습니다, 그리고 나는 PHP newb 이후로 나는 완전히 확실하지 왜. 어떤 제안이나 조언을 많이 주시면 감사하겠습니다. 먼저 문제 섹션을 게시하고 전체 PHP 파일을 두 번째로 게시하므로 문제가있는 섹션의 컨텍스트를 모두 볼 수 있습니다.PHP 명세서, HTML 및 RSS
문제 섹션 :
echo '<div class="panel iq-news">';
echo '<h4><span><a href="/category/blog/feed"><img src="/wp-content/themes/iq/images/rss-icon.gif" alt="Subscribe to our feed"/></a></span>IQNavigator Blog</h4>';
<?php
query_posts('category_name=Blog&showposts=2');
if (have_posts()) : ?>
echo '<ul>';
<?php while (have_posts()) : the_post(); ?>
echo '<li><a href="<?php the_permalink();?>"><?php the_title();?> </a></li>';
<?php endwhile;?>
echo '</ul>';
<?php endif;?>
echo '<div class="twitter">';
echo '<p id="twitter-updates">';
<?php twitter_updates();?>
echo '</p>';
echo '<p class="text-center"><a href="http://twitter.com/iqnavigator">Follow us on twitter</a></p>';
echo '</div>';
echo '</div>';
문맥상의 이유로 전체 이놈 긴 문 :
<div class="sidebar">
<?php
if (!is_search() && !is_page('Our Clients') && !is_archive()){
if($post->post_parent) {
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0&depth=1&exclude=85,87,89,181,97,184");
}
else {
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&depth=1&exclude=85,87,89,181,97,184");
}
if ($children) { ?>
<div class="panel links subnav">
<h3>In This Section</h3>
<ul class="subnav">
<?php echo $children; ?>
</ul>
<p> </p>
</div>
<?php
}
}
if(is_page('Our Clients') || in_category('Our Clients') || is_category('Our Clients'))
{
echo '<div class="panel links subnav">';
echo '<h3>In This Section</h3>';
echo '<ul class="subnav">';
wp_list_categories('child_of=21&title_li=');
echo '</ul>';
echo '<p> </p>';
echo '</div>';
}
else if (in_category('Blog'))
{
//PUT YOUR CODE HERE
// echo get_page_content(34);
echo '<div class="panel featured-resource">';
echo '<h4>Blog Contributors</h4>';
echo '<ul class"subnav">';
echo '<li><a href="/company/executive-team/john-f-martin/">John Martin</a></li>';
echo '<li><a href="/company/executive-team/kieran-brady/">Kieran Brady</a></li>';
echo '<li><a href="/company/executive-team/art-knapp/">Art Knapp</a></li>';
echo '</ul>';
echo '</div>';
echo '<div class="panel iq-news">';
echo '<h4><span><a href="/category/blog/feed"><img src="/wp-content/themes/iq/images/rss-icon.gif" alt="Subscribe to our feed"/></a></span>IQNavigator Blog</h4>';
<?php
query_posts('category_name=Blog&showposts=2');
if (have_posts()) : ?>
echo '<ul>';
<?php while (have_posts()) : the_post(); ?>
echo '<li><a href="<?php the_permalink();?>"><?php the_title();?> </a></li>';
<?php endwhile;?>
echo '</ul>';
<?php endif;?>
echo '<div class="twitter">';
echo '<p id="twitter-updates">';
<?php twitter_updates();?>
echo '</p>';
echo '<p class="text-center"><a href="http://twitter.com/iqnavigator">Follow us on twitter</a></p>';
echo '</div>';
echo '</div>';
//END CODE HERE
}
if (!is_page('Resources'))
{
?>
<div class="panel featured-resource">
<h4>Featured Resource</h4>
<div class="embed">
<?php
$custom_fields = get_post_custom();
$featured_video_code = $custom_fields['Featured Video Code'];
if($featured_video_code)
{
foreach ($featured_video_code as $key => $value)
{
$the_code = $value;
}
$featured_video_link = $custom_fields['Featured Video Link'];
foreach ($featured_video_link as $key => $value)
{
$the_link = $value;
}
$featured_video_text = $custom_fields['Featured Video Text'];
foreach ($featured_video_text as $key => $value)
{
$the_text = $value;
}
if($the_code)
{
echo $the_code;
}
if($the_text)
{
echo '<ul>';
echo '<li>';
if($the_link)
{
echo '<a href="' . $the_link . '" class="video" target="_blank">' . $the_text . '</a>';
}
else
{
echo $the_text;
}
echo '</li>';
echo '</ul>';
}
}
?>
<div class="clr"></div>
<div class="blue-bars">
<a href="<?php bloginfo('template_directory');?>/more-info.php" class="more-info" rel="facebox">Request More Info</a>
<a href="<?php bloginfo('template_directory');?>/resource-form.php?id=701000000009E" class="view-demos" rel="facebox">Schedule a Demo</a>
</div>
</div>
<div id="content">
).이 코드는 사용하고있는 것보다 훨씬 더 간결합니다. 나는 (아마도) 바보 같은 후속 질문을 할 것이다. 나는 $ my_query를 아무거나 호출 할 수 있을까? 아니면 $ query_posts와 같은 특별한 것이 필요 할까? – poindexter
무시; 나는 그 부분을 알아 냈다 ... :) – poindexter
결국, 무엇이 잘못 되었습니까? 그 일 했니? 그렇다면 대답을 수락하십시오 : stackoverflow.com/faq – markratledge