始终显示默认的WordPress小工具

时间:2014-08-21 作者:user3351284

我只在侧边栏中添加了3个小部件,但是当我将它们的可见性设置为“隐藏在帖子页面中”时,它们会消失,但所有默认小部件都会出现。我想删除显示的默认小部件,因为我不想在我的帖子页面上有任何小部件。下面是显示所有默认小部件的代码。

<div class="widget widget_search widget-widget_search">
  <div class="widget-wrap widget-inside">
    <?php get_search_form(); ?>
  </div>
</div>

<div class="widget widget_pages widget-widget_pages">
  <div class="widget-wrap widget-inside">
    <h3 class="widget-title"><?php _e( \'Pages\', \'alkane\' ); ?></h3>
      <ul><?php wp_list_pages(\'title_li=\'); ?></ul>
  </div>
</div>

<div class="widget widget_categories widget-widget_categories">
  <div class="widget-wrap widget-inside">
    <h3 class="widget-title"><?php _e( \'Categories\', \'alkane\' ); ?></h3>
      <ul><?php wp_list_categories(\'title_li=\'); ?></ul>
  </div>
</div>

<div class="widget widget_archive widget-widget_archive">
  <div class="widget-wrap widget-inside">
    <h3 class="widget-title"><?php _e( \'Archives\', \'alkane\' ); ?></h3>
      <ul><?php wp_get_archives(\'type=monthly\'); ?></ul>
  </div>
</div>

<div class="widget widget_calendar widget-widget_calendar">
  <div class="widget-wrap widget-inside">
    <h3 class="widget-title"><?php _e( \'Calendar\', \'alkane\' ); ?></h3>
    <?php get_calendar(); ?>
  </div>
</div>

<div class="widget widget_recent_entries widget-widget_recent_entries">
  <div class="widget-wrap widget-inside">
    <h3 class="widget-title"><?php _e( \'Recent Posts\', \'alkane\' ); ?></h3>
      <ul><?php wp_get_archives(\'type=postbypost&limit=5\'); ?></ul>
  </div>
</div>

<div class="widget widget_tag_cloud widget-widget_tag_cloud">
  <div class="widget-wrap widget-inside">
    <h3 class="widget-title"><?php _e( \'Tag Cloud\', \'alkane\' ); ?></h3>
    <?php wp_tag_cloud(\'smallest=10&largest=20&number=30&unit=px&format=flat&orderby=name\'); ?>
  </div>
</div>

<div class="widget widget_text widget-widget_text">
  <div class="widget-wrap widget-inside">
    <h3 class="widget-title"><?php _e( \'About Alkane\', \'alkane\' ); ?></h3>
    <div class="textwidget"><?php printf( __( \'%s\', \'alkane\' ), $alkane_theme_data[\'Description\'] ); ?></div>
  </div>
</div>

<div class="widget widget_links widget-widget_links">
  <div class="widget-wrap widget-inside">
    <h3 class="widget-title"><?php _e( \'Blogroll\', \'alkane\' ); ?></h3>
      <ul><?php wp_list_bookmarks(\'title_li=&categorize=0\'); ?></ul>
  </div>
</div>

<div class="widget widget_meta widget-widget_meta">
  <div class="widget-wrap widget-inside">
    <h3 class="widget-title"><?php _e( \'Meta\', \'alkane\' ); ?></h3>
      <ul>
        <?php wp_register(); ?>
        <li><?php wp_loginout(); ?></li>
        <li><a href="<?php bloginfo( \'rss2_url\' ); ?>" title="Syndicate this site using RSS 2.0">Entries <abbr title="Really Simple Syndication">RSS</abbr></a></li>
        <li><a href="<?php bloginfo( \'comments_rss2_url\' ); ?>" title="The latest comments to all posts in RSS">Comments <abbr title="Really Simple Syndication">RSS</abbr></a></li>
        <li><a href="http://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform.">WordPress.org</a></li>
        <?php wp_meta(); ?>
      </ul>
  </div>
</div>

1 个回复
SO网友:user3351284

我已经删除了上面提到的代码行,只在侧栏中留下了剩余的代码。php。问题是它们是硬编码的,所以如果可见性设置为隐藏到侧栏小部件,它们就会出现。

结束

相关推荐

Multiple widgets in wordpress

我已经创建了一个wordpress小部件。它在小部件选项中有一个下拉列表。下拉列表包含“facebook”和“twitter”。如果管理员选择“twitter”,那么twitter关注者计数将显示在小部件中,与facebook的情况类似。使用jquery,该计数显示在id为“social count”的div中。当页面加载时,jquery ajax将获取计数并将其插入到“社交计数”中。问题是它在单个实例中运行良好。但是,如果在侧栏中添加了2个实例,则在这两个实例中都会显示最新的计数,因为我使用的是$(“.