Suporte » Temas » Excluir categoria APENAS da página principal.

  • Resolvido Lara C

    (@larissacas)


    Oi, pessoal.

    Na verdade, me perdi, tanto que não acessava que nem sei realmente se é a versão 3.2 que estou usando, mas não é a atualização da 3.2.1, se não for a 3.2 deve ser a 3.1.4

    Tem muita diferença de uma pra outra?

    Estou usando o template Platform – Page Lines.

    Preciso que apareça na página inicial apenas os posts de uma categoria (português), deixando os da outras categoria (inglês) em uma página à parte para isto.

    Não, não serve tradução automática, pois tem coisas no post em inglês que precisam ser contextualizadas.

    Em template.postloop.php fiz a alteração do código

    // Start of 'The Loop'
    if(have_posts()){
    while (have_posts()) : the_post();

    por

    // Start of 'The Loop'
    if(have_posts()){
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("cat=-10&paged=$paged");
    while (have_posts()) : the_post();

    E realmente, na página inicial ficou perfeito, apenas os posts em português…. porém, na categoria inglês também. Em todas as páginas os posts em inglês eram omitidos.

    Como faço para isto acontecer apenas na página inicial?

    Meu index.php não tem código, ele linka pra outras páginas.

    Eu que já não sei nada de php fique super perdida com esse template, todo fragmentado em mil phps diferentes, um linkando pro outro.

    Quem puder ajudar, agradeço muito.

Visualizando 14 respostas - 1 até 14 (de um total de 14)
  • Eu tenho uma sugestão melhor.

    Remova esse query_posts que vc fez e adicione a função ao seu function, isso irá funcionar muito melhor.

    function my_query_posts_home($query){
    	if ($query->is_home){
    		$query->set('cat', '10');
    	}
    	return $query;
    }
    add_filter('pre_get_posts','my_query_posts_home');

    As vantagens desta função no lugar do query_post são:
    1) Só afeta a home listando posts da categoria escolhida.
    2) Não afeta a paginação do site caso ela esteja sendo usada.
    3) Otimiza a busca do sistema por posts para serem apresentados na home, a busca é planejada antes do sistema ir ao banco de dados e traz para a home só aquilo que realmente precisar se exibido.

    Criador do tópico Lara C

    (@larissacas)

    Obrigada, Myst1010, mas não funcionou… não mudou nada na home, e os posts da categoria inglês continuam aparecendo.

    Onde exatamente eu devo colar esse código?

    no arquivo function.php do seu tema.

    Só uma pequena correção, infelizmente eu coloquei para exibir somente a categoria de ID 10 quando na verdade deveria excluir.

    Então agora corrigido o código seria este

    function my_query_posts_home($query){
    	if ($query->is_home){
    		$query->set('cat', '-10');
    	}
    	return $query;
    }
    add_filter('pre_get_posts','my_query_posts_home');

    A correção foi no 'cat', '10' para 'cat', '-10' como era pra eu ter feito no código anterior.

    Criador do tópico Lara C

    (@larissacas)

    Mas se eu coloco isso no template.postloop.php não acontece nada! =(

    é pra colocar o código em qual php?

    Até mudar a sidebar pra aparecer só em português na home e só em inglês na categoria eu fiz… falta só filtrar esses posts na home também.

    Mas se eu coloco isso no template.postloop.php não acontece nada! =(

    Não, não irá funcionar.

    é pra colocar no arquivo function.php

    Caso seu tema não tenha este arquivo é só criar e colocar no mesmo diretório que está o seu arquivo index.php

    Criador do tópico Lara C

    (@larissacas)

    ahhh Myst1010! Muito obrigada! *.*

    Agora parece até que tem um diretório /en! \o/

    http://www.albumcarioca.blog.br/

    Bacana, que bom que funcionou.

    Se me permite ser intrometido gostaria de lhe dar uma sugestão.
    Não deixe tantos posts sendo listados na home ou então diminua a quantidade de imagens.

    A quantidade de imagens faz com que o site demore a abrir e isso é ruim porque as pessoas não tem a mínima paciência para esperar um site abrir.

    Vc pode usar a tag <!–more–> no seu post que faz com que tudo antes desta tag apareça na home e o restante só apareça ao visualizar o post completo.

    Isso é interessante porque além de deixar sua home mais rápido por não carregar tanta coisa, deixa o leitor com um gostinho de quero mais se vc criar a parte que irá para a home de forma a estigar a curiosidade do leitor.

    Bom, é só uma sugestão, parabéns pelo projeto e boa sorte.

    Criador do tópico Lara C

    (@larissacas)

    Agradeço a sugestão.

    Mas o cliente pede que os posts apareçam por completo. E ele não tem um número certo de imagens por post, depende do tema que aborda.

    Ainda vou estar com ele, e sugerir, por exemplo, que quando um post precisar de muitas imagens para produzir o sentido desejado, que faça “parte 1” e “parte 2”.

    Mas aí já não é muito comigo.

    Mais uma vez, obrigada.

    Eu queria deletar a categoria 29, mas não sei onde colocar esse código no meu function.php:

    <?php
    load_theme_textdomain( 'dld_theme', TEMPLATEPATH . '/languages' );
    $locale = get_locale();
    $locale_file = TEMPLATEPATH . "/languages/$locale.php";
    if ( is_readable( $locale_file ) )
    require_once( $locale_file );
    
    remove_action('wp_head', 'wp_generator');
    add_filter('show_admin_bar', '__return_false');
    add_filter('widget_text', 'do_shortcode');
    
    function dld_fancybox() {
    echo "<script type=\"text/javascript\" src=\""; ?><?php bloginfo('template_url'); ?><?php echo "/fancybox/jquery.fancybox-1.3.4.pack.js\"></script>";
    echo "<script type=\"text/javascript\" src=\""; ?><?php bloginfo('template_url'); ?><?php echo "/fancybox/jquery.mousewheel-3.0.4.pack.js\"></script>";
    echo "<link rel=\"stylesheet\" href=\""; ?><?php bloginfo('template_url'); ?><?php echo "/fancybox/jquery.fancybox-1.3.4.css\" type=\"text/css\" media=\"screen\">\n";
    echo "<script type=\"text/javascript\">jQuery.noConflict();  jQuery(function(){  var thumbnails = 'a:has(img)[href$=\".bmp\"],a:has(img)[href$=\".gif\"],a:has(img)[href$=\".jpg\"],a:has(img)[href$=\".jpeg\"],a:has(img)[href$=\".png\"],a:has(img)[href$=\".BMP\"],a:has(img)[href$=\".GIF\"],a:has(img)[href$=\".JPG\"],a:has(img)[href$=\".JPEG\"],a:has(img)[href$=\".PNG\"]';  var posts = jQuery('.post');  posts.each(function() { jQuery(this).find(thumbnails).addClass(\"fancybox\").attr('rel','fancybox'+posts.index(this)) });  jQuery(\"a.fancybox\").fancybox({ 'transitionIn' : 'none', 'transitionOut' : 'none', 'titlePosition' : 'inside', 'titleFormat' : function(title, currentArray, currentIndex, currentOpts) { return '<span id=\"fancybox-title-inside\">Imagem ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? '  -  ' + title : '') + '</span>'; } });  });</script>\n";
    }
    
    register_nav_menus( array(  'primary' => __( 'Header Menu', 'dld_theme' ),  ) );
    function dldwp_page_menu_args( $args ) { $args['show_home'] = true; return $args; }
    add_filter( 'wp_page_menu_args', 'dldwp_page_menu_args' );
    
    function blog_widgets_init() {
    	register_sidebar( array(
    		'name' => 'Sidebar 1',
    		'id' => 'sidebar-1',
    		'description' => 'Sidebar 1',
    		'before_widget' => ' <!--widget--><div id="%1$s" class="widget %2$s">',
    		'after_widget'  => '<div class="both"></div> </div> <div class="both"></div><!--//widget-->  ',
    		'before_title'  => '<h2 class="title">',
    		'after_title'   => '</h2>',
    	) );
    	register_sidebar( array(
    		'name' => 'Sidebar 2',
    		'id' => 'sidebar-2',
    		'description' => 'Sidebar 2',
    		'before_widget' => ' <!--widget--><div id="%1$s" class="widget-other %2$s">',
    		'after_widget'  => '<div class="both"></div> </div> <div class="both"></div><!--//widget-->  ',
    		'before_title'  => '<h2 class="title">',
    		'after_title'   => '</h2>',
    	) );
    	register_sidebar( array(
    		'name' => 'Footer 1',
    		'id' => 'footer-1',
    		'description' => 'Footer 1',
    		'before_widget' => ' <!--widget--><div id="%1$s" class="widget %2$s">',
    		'after_widget'  => '<div class="both"></div> </div> <div class="both"></div><!--//widget-->  ',
    		'before_title'  => '<h2 class="title">',
    		'after_title'   => '</h2>',
    	) );
    	register_sidebar( array(
    		'name' => 'Footer 2',
    		'id' => 'footer-2',
    		'description' => 'Footer 2',
    		'before_widget' => ' <!--widget--><div id="%1$s" class="widget %2$s">',
    		'after_widget'  => '<div class="both"></div> </div> <div class="both"></div><!--//widget-->  ',
    		'before_title'  => '<h2 class="title">',
    		'after_title'   => '</h2>',
    	) );
    	register_sidebar( array(
    		'name' => 'Footer 3',
    		'id' => 'footer-3',
    		'description' => 'Footer 3',
    		'before_widget' => ' <!--widget--><div id="%1$s" class="widget %2$s">',
    		'after_widget'  => '<div class="both"></div> </div> <div class="both"></div><!--//widget-->  ',
    		'before_title'  => '<h2 class="title">',
    		'after_title'   => '</h2>',
    	) );
    	register_sidebar( array(
    		'name' => 'Footer 4',
    		'id' => 'footer-4',
    		'description' => 'Footer 4',
    		'before_widget' => ' <!--widget--><div id="%1$s" class="widget %2$s">',
    		'after_widget'  => '<div class="both"></div> </div> <div class="both"></div><!--//widget-->  ',
    		'before_title'  => '<h2 class="title">',
    		'after_title'   => '</h2>',
    	) );
    }
    add_action( 'widgets_init', 'blog_widgets_init' );
    
    function dld_related_posts() {
    $relatedcat = get_option('simplethird_relatedposts');
    if ($relatedcat == 'Tags') { dld_related_tags(); }
    elseif ($relatedcat == 'Hide') { }
    else { dld_related_cat(); }
    }
    function dld_related_tags() {
    $orig_post = $post;
    global $post;
    $tags = wp_get_post_tags($post->ID);
    $tag_ids = array();
    foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
    $args=array(
      'tag__in' => $tag_ids,
      'post__not_in' => array($post->ID),
      'posts_per_page'=> 5,
      'caller_get_posts'=> 1
    );
    $my_query = new wp_query( $args );
    if( $my_query->have_posts() ) {
      echo "<ul class=\"related-posts\">\n";
      echo "<h3>". __( 'Related Posts', 'dld_theme' )."</h3>\n";
      while( $my_query->have_posts() ) { $my_query->the_post();
    ?>
    <li><a>" title="<?php the_title(); ?>"><?php if( has_post_thumbnail() ) { the_post_thumbnail( array(120,120) ); } else { ?><img src="<?php echo dld_thumb('thumbnail'); ?>" alt=""><?php } ?><?php the_title(); ?></a></li>
    <?php } echo "<div style=\"clear:both;\"></div> \n"; }
    $post = $orig_post;
    wp_reset_query();
    }
    function dld_related_cat() {
    $orig_post = $post;
    global $post;
    $categories = get_the_category($post->ID);
    $category_ids = array();
    foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
    $args=array(
      'category__in' => $category_ids,
      'post__not_in' => array($post->ID),
      'posts_per_page'=> 5,
      'caller_get_posts'=> 1
    );
    $my_query = new wp_query( $args );
    if( $my_query->have_posts() ) {
      echo "<ul class=\"related-posts\">\n";
      echo "<h3>". __( 'Related Posts', 'dld_theme' )."</h3>\n";
      while( $my_query->have_posts() ) { $my_query->the_post();
    ?>
    <li><a>" title="<?php the_title(); ?>"><?php if( has_post_thumbnail() ) { the_post_thumbnail( array(120,120) ); } else { ?><img src="<?php echo dld_thumb('thumbnail'); ?>" alt=""><?php } ?><?php the_title(); ?></a></li>
    <?php } echo "<div style=\"clear:both;\"></div> \n"; }
    $post = $orig_post;
    wp_reset_query();
    }
    
    function dld_pagination($pages = '', $range = 2) {
      $showitems = ($range * 2)+1;
      global $paged;
      if(empty($paged)) $paged = 1;
      if($pages == ''){
    	global $wp_query;
    	$pages = $wp_query->max_num_pages;
    	if(!$pages){$pages = 1;}
      }
      if(1 != $pages){
    	echo "<div class=\"pagination\">";
    	echo "<span class=\"pages\">".__( 'Page ', 'dld_theme' ).$paged." de ".$pages."</span>";
    	if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>« ". __( 'Previous', 'dld_theme' )."</a>";
    	for ($i=1; $i <= $pages; $i++) {
    	  if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )) {
    		echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"<a href='".get_pagenum_link($i)."'>".$i."</a>";
    	  }
    	}
    	if ($paged < $pages && $showitems < $pages) echo "<a>". __( 'Next', 'dld_theme' )." »</a>";
    	echo "</div>\n";
      }
    }
    
    function dld_share() {
    echo "<span class=\"dld-share\">\n";
    echo "  <span class=\"share-twitter\"><a href="http://twitter.com/share"><?php the_permalink();?><?php echo "\" data-text=\"";?><?php the_title(); ?><?php echo "\" data-count=\"horizontal\">Tweet</a><script type=\"text/javascript\" src=\"http://platform.twitter.com/widgets.js\"></script></span>\n";
    echo "  <span class=\"share-plusone\"><g:plusone size=\"medium\" href=\""; ?><?php the_permalink();?><?php echo "\"></g:plusone></span>\n";
    echo "  <span class=\"share-facebook\"><iframe src=\"http://www.facebook.com/plugins/like.php?href="; ?><?php the_permalink();?><?php echo "&layout=button_count&show_faces=false&width=85&action=like&colorscheme=light&height=21\" scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:85px; height:21px;\" allowTransparency=\"true\"></iframe></span>\n";
    echo "<div style=\"clear:both;\"></div> </span>\n";
    }
    function dld_facebook_thumb() {global $post, $posts;  $first_img = '';  ob_start();  ob_end_clean();  $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);  $first_img = $matches [1] [0];  return $first_img;}
    function dld_facebook_header() {
    if( is_single() ) :
      echo "<meta property=\"og:title\" content=\""?><?php the_title(); ?><?php echo "\">\n";
      echo "<meta property=\"og:type\" content=\"article\">\n";
      echo "<meta property=\"og:url\" content=\""?><?php the_permalink(); ?><?php echo "\">\n";
      echo "<meta property=\"og:image\" content=\""?><?php if (dld_facebook_thumb()) { echo dld_facebook_thumb(); } else { ?><?php bloginfo('template_directory'); ?>/i/facebook-thumb.png<?php }?><?php echo "\">\n";
    else :
      echo "<meta property=\"og:image\" content=\""?><?php bloginfo('template_directory'); ?><?php echo "/i/facebook-thumb.png\">\n";
    endif;
    }
    
    add_filter('get_comments_number', 'dld_comment_count', 0);
    function dld_comment_count( $count ) { global $id; $comments_by_type = &separate_comments(get_comments('post_id=' . $id)); return count($comments_by_type['comment']); }
    function dld_list_pings($comment, $args, $depth) { $GLOBALS['comment'] = $comment; ?>
    	<li id="comment-<?php comment_ID(); ?>"><?php comment_author_link(); ?><span><?php comment_date('d m y'); ?></span>
    <?php }
    function dld_comment($comment, $args, $depth) { $GLOBALS['comment'] = $comment;
    ?>
    <li id="comment-<?php comment_ID() ?>">
      <div id="div-comment-<?php comment_ID() ?>" <?php comment_class(); ?>>
        <?php echo get_avatar($comment, 50, ''); ?>
        <div class="comment-content the-content">
          <p class="comment-author"><strong><?php comment_author_link(); ?></strong> <em class="comment-date"><?php printf( get_comment_time('d F Y')) ?><?php edit_comment_link(__('{Edit}', 'dld_theme'),'  ','') ?></p>
          <?php if ($comment->comment_approved == '0') : ?><p><em><?php _e('Your comment will appear after being approved by admin.', 'dld_theme') ?></em></p><?php endif; ?><?php comment_text() ?>
          <?php comment_reply_link(array_merge( $args, array('reply_text' => __('Reply', 'dld_theme'), 'add_below' => 'div-comment', 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
        </div>
      </div>
    <?php }
    
    function dld_comment_form(){ global $user_identity, $id; if ( ! comments_open() ) :
    ?>
      <div class="nocomments"><p><?php _e("Comments Closed", "dld_theme"); ?></p></div>
      <?php elseif (comments_open()) : //Comment Form ?>
      <div id="respond" class="comment-form">
        <h3><?php comment_form_title( __( 'Leave a Comment', 'dld_theme' ), __( 'Leave a Reply to %s', 'dld_theme' ) ); ?></h3>
        <p class="cancel-comment-reply"><?php cancel_comment_reply_link(); ?></p>
        <?php if ( get_option('comment_registration') && !$user_ID ) : ?>
          <p class="comment-loggedin"><?php _e("You have to be", "dld_theme"); ?> <a>/wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>"><?php _e("logged in", "dld_theme"); ?></a> <?php _e("to be able to comment.", "dld_theme"); ?></p>
        <?php else : ?>
            <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="comment-form">
            <?php if ( is_user_logged_in() ) : ?>
            <p><a>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a>" title="Log out of this account">Log out »</a></p>
            <?php else : ?>
            <p><label><?php _e("Name", "dld_theme"); ?><span>*</span></label><input type="text" name="author" class="comment-input" id="author" size="22" tabindex="1" <?php if (isset($req)) echo "aria-required='true'"; ?> /></p>
            <p><label><?php _e("Email", "dld_theme"); ?><span>*</span></label><input type="text" name="email"  class="comment-input" id="email" size="22" tabindex="2" <?php if (isset($req)) echo "aria-required='true'"; ?> /></p>
            <p><label><?php _e("Website", "dld_theme"); ?></label><input type="text" name="url"  class="comment-input" id="url" size="22" tabindex="3"/></p>
            <?php endif; ?>
            <p id="comment-textarea-wrapper">
              <label><?php _e("Message", "dld_theme"); ?><span>*</span></label>
              <textarea name="comment" id="comment" rows="10" tabindex="4"></textarea>
            </p>
            <p id="required-field"><?php _e("<span>*</span> Required Field", "dld_theme"); ?></p>
            <p>
              <input name="submit" type="submit" id="submit" tabindex="5" value="<?php _e("Send", "dld_theme"); ?>" />
              <?php comment_id_fields(); ?>
            </p>
            <?php do_action('comment_form', isset($post->ID)); ?>
            </form>
        <?php endif;// If registration required and not logged in ?>
      <div class="clear"></div>
      </div><!--#respond-->
    <?php endif; }
    
    function youtube_shortcode($atts, $content = null) {
    extract(shortcode_atts(array(
    	'video'  => '',
    	'width'  => '600',
    	'height' => '370'
    	), $atts));
      return '<div class="video youtube-video"><iframe src="http://www.youtube.com/embed/'.$video.'" width="'.$width.'" height="'.$height.'" frameborder="0" allowfullscreen></iframe></div>';
    }
    add_shortcode('youtube', 'youtube_shortcode');
    function add_button_youtube() {
       if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') )
         return;
       if ( get_user_option('rich_editing') == 'true') {
         add_filter('mce_external_plugins', 'add_buttonyoutube_tinymce_plugin');
         add_filter('mce_buttons', 'register_button_youtube');
       }
    }
    add_action('init', 'add_button_youtube');
    function register_button_youtube($buttons) { array_push($buttons, "|", "youtube"); return $buttons; }
    function add_buttonyoutube_tinymce_plugin($plugin_array) { $plugin_array['youtube'] = get_bloginfo('template_url').'/js/mybuttons.js'; return $plugin_array; }
    
    function vimeo_shortcode($atts, $content = null) {
       extract(shortcode_atts(array(
    			'video'  => '',
    			'width'  => '600',
    			'height' => '370'
    			), $atts));
    		return '<div class="video vimeo-video"><iframe src="http://player.vimeo.com/video/'.$video.'?title=0&byline=0&portrait=0" width="'.$width.'" height="'.$height.'" frameborder="0"></iframe></div>';
    }
    add_shortcode('vimeo', 'vimeo_shortcode');
    function add_button_vimeo() {
       if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') )
         return;
       if ( get_user_option('rich_editing') == 'true') {
         add_filter('mce_external_plugins', 'add_buttonvimeo_tinymce_plugin');
         add_filter('mce_buttons', 'register_button_vimeo');
       }
    }
    add_action('init', 'add_button_vimeo');
    function register_button_vimeo($buttons) { array_push($buttons, "|", "vimeo"); return $buttons; }
    function add_buttonvimeo_tinymce_plugin($plugin_array) { $plugin_array['vimeo'] = get_bloginfo('template_url').'/js/mybuttons.js'; return $plugin_array; }
    
    add_theme_support( 'post-thumbnails' );
    set_post_thumbnail_size( 100, 63 );
    add_image_size( 'large_thumb', 90, 90, true );
    add_image_size( 'small_thumb', 75, 75, true );
    
    function dld_thumb($size = "medium", $add = ""){
    global $wpdb, $post;
    $thumb = $wpdb->get_row("SELECT ID, post_title FROM {$wpdb->posts} WHERE post_parent = {$post->ID} AND post_mime_type LIKE 'image%' ORDER BY menu_order");
    if(!empty($thumb)){ $image = image_downsize($thumb->ID, $size); print "{$image[0]}"; }
    else { print get_bloginfo('template_directory')."/i/thumbnail.png"; }
    }
    
    function dld_excerpt($limit) {
    $excerpt = explode(' ', get_the_excerpt(), $limit);
    if (count($excerpt)>=$limit) { array_pop($excerpt); $excerpt = implode(" ",$excerpt).'...';	} else { $excerpt = implode(" ",$excerpt); }
    $excerpt = preg_replace('<code>\[[^\]]*\]</code>','',$excerpt);
    return $excerpt;
    }
    function dld_content($limit) {
    $content = explode(' ', get_the_content(), $limit);
    if (count($content)>=$limit) { array_pop($content); $content = implode(" ",$content).'...'; } else { $content = implode(" ",$content); }
    $content = preg_replace("/<img[^>]+\>/i", "", $content);
    $content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]>', $content);
    return $content;
    }
    
    add_filter('gallery_style',
    create_function(
    	'$css',
    	'return preg_replace("#<style type=\'text/css\'>(.*?)</style>#s", "", $css);'
    	)
    );
    
    add_shortcode('wp_caption', 'fixed_img_caption_shortcode');
    add_shortcode('caption', 'fixed_img_caption_shortcode');
    function fixed_img_caption_shortcode($attr, $content = null) {
    	$output = apply_filters('img_caption_shortcode', '', $attr, $content);
    	if ( $output != '' ) return $output;
    	extract(shortcode_atts(array(
    		'id'=> '',
    		'align'	=> 'alignnone',
    		'width'	=> '',
    		'caption' => ''), $attr));
    	if ( 1 > (int) $width || empty($caption) )
    	return $content;
    	if ( $id ) $id = 'id="' . esc_attr($id) . '" ';
    	return '<div ' . $id . 'class="wp-caption ' . esc_attr($align)
    	. '">'
    	. do_shortcode( $content ) . '<p class="wp-caption-text">'
    	. $caption . '</p></div>';
    }
    
    function dld_remove_recent_comments_style() { add_filter( 'show_recent_comments_widget_style', '__return_false' ); }
    add_action( 'widgets_init', 'dld_remove_recent_comments_style' );
    
    function dld_remove_widgets() {
        unregister_widget( 'WP_Widget_Meta' );
        unregister_widget( 'WP_Widget_Pages' );
        unregister_widget( 'WP_Widget_Search' );
    }
    add_action( 'widgets_init', 'dld_remove_widgets' );
    
    function mySearchPostsFilter($query) { if ($query->is_search) { $query->set('post_type', 'post'); } return $query; }
    add_filter('pre_get_posts','mySearchPostsFilter');
    
    /*
    * ==========================
    * theme options by difluir
    * ==========================
    */
    $themename = "Simple Third";
    $shortname = "simplethird";
    
    $options = array (
    array( "name" => $themename." Options",	"type" => "title"),
    
    /* general */
    array( "name" => __('General', 'dld_theme'), "type" => "section"),
    array( "type" => "open"),
    	array(
    		"name" => __('Custom Favicon', 'dld_theme'),
    		"desc" => __('A favicon is a 16x16 pixel icon that represents your site; paste the URL to a .ico or .png image that you want to use as the image', 'dld_theme'),
    		"id" => $shortname."_favicon",
    		"type" => "text",
    		"std" => get_bloginfo('template_url')."/i/favicon.png"
    		),
    	array(
    		"name" => __('Feedburner URL', 'dld_theme'),
    		"desc" => __('Feedburner is a Google service that takes care of your RSS feed. Paste your Feedburner URL here to let readers see it in your website', 'dld_theme'),
    		"id" => $shortname."_feedburner",
    		"type" => "text",
    		"std" => get_bloginfo('rss2_url')
    		),
    	array(
    		"name" => __('Google Analytics Code', 'dld_theme'),
    		"desc" => __('You can paste your Google Analytics or other tracking code in this box. This will be automatically added to the footer', 'dld_theme'),
    		"id" => $shortname."_ga_code",
    		"type" => "textarea",
    		"std" => ""
    		),
    	array(
    		"name" => __('Custom CSS', 'dld_theme'),
    		"desc" => __('Want to add any custom CSS code? Put in here, and the rest is taken care of. This overrides any other stylesheets. eg: a.button{color:#000;}', 'dld_theme'),
    		"id" => $shortname."_custom_css",
    		"type" => "textarea",
    		"std" => ""
    		),
    array( "type" => "close"),
    
    /* Posts */
    array( "name" => __('Posts', 'dld_theme'), "type" => "section"),
    array( "type" => "open"),
    	array(
    		"name" => __('Related Posts', 'dld_theme'),
    		"desc" => __('Select how the theme will show the related posts', 'dld_theme'),
    		"id" => $shortname."_relatedposts",
    		"type" => "select",
    		"options" => array( "Categories", "Tags", "Hide" ),
    		"std" => "Categories"
    		),
    array( "type" => "close"),
    
    );
    
    function dldtheme_add_admin() {
    global $themename, $shortname, $options;
      if ( $_GET['page'] == basename(__FILE__) ) {
    	if ( 'save' == $_REQUEST['action'] ) {
    	  foreach ($options as $value) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
    	  foreach ($options as $value) {
    		if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ]  ); } else { delete_option( $value['id'] ); } }
    		header("Location: admin.php?page=functions.php&saved=true");
    		die;
    	  }
    	else if( 'reset' == $_REQUEST['action'] ) {
    	  foreach ($options as $value) {delete_option( $value['id'] );}
    	  header("Location: admin.php?page=functions.php&reset=true");
    	  die;
    	}
      }
    add_theme_page($themename, $themename, 'edit_themes', basename(__FILE__), 'dldtheme_admin');
    }
    
    function dldtheme_add_init() {
    $file_dir=get_bloginfo('template_directory');
    wp_enqueue_style("functions", $file_dir."/functions/functions.css", false, "1.0", "all");
    }
    
    function dldtheme_admin() {
    global $themename, $shortname, $options;
    $i=0;
    if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
    if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings reset.</strong></p></div>';
    ?>
    <div class="wrap dld_wrap">
    <h2><?php echo $themename; ?> <?php _e("Settings", "dld_theme"); ?></h2>
    <div class="dld_opts">
    <form method="post">
    <?php foreach ($options as $value) {
    switch ( $value['type'] ) {
    case "open":
    ?>
    <?php break;
    case "close":
    ?>
    </div>
    </div>
    
    <?php break;
    case "title":
    ?>
    <p><?php _e("To easily use the", "dld_theme"); ?> <?php echo $themename;?> <?php _e("theme, you can use the menu below.", "dld_theme"); ?></p>
    <?php break;
    case 'text':
    ?>
    <div class="dld_input dld_text">
      <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
      <input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id'])  ); } else { echo $value['std']; } ?>" />
      <small><?php echo $value['desc']; ?></small>
    <div class="clear"></div>
    </div>
    <?php
    break;
    case 'textarea':
    ?>
    <div class="dld_input dld_textarea">
      <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
      <textarea name="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id']) ); } else { echo $value['std']; } ?></textarea>
      <small><?php echo $value['desc']; ?></small>
    <div class="clear"></div>
    </div>
    <?php
    break;
    case 'select':
    ?>
    <div class="dld_input dld_select">
      <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
      <select name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>"><?php foreach ($value['options'] as $option) { ?>
      <option <?php if (get_settings( $value['id'] ) == $option) { echo 'selected="selected"'; } ?>><?php echo $option; ?></option>
      <?php } ?></select>
      <small><?php echo $value['desc']; ?></small>
    <div class="clear"></div>
    </div>
    <?php
    break;
    case "checkbox":
    ?>
    <div class="dld_input dld_checkbox">
      <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
      <?php if(get_option($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = "";} ?>
      <input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />
      <small><?php echo $value['desc']; ?></small>
    <div class="clear"></div>
    </div>
    <?php break;
    case "section":
    
    $i++;
    ?>
    <div class="dld_section">
    <div class="dld_title">
        <h3><?php echo $value['name']; ?></h3>
        <span class="submit"><input name="save<?php echo $i; ?>" type="submit" value="<?php _e("Save changes", "dld_theme"); ?>" /></span>
    <div class="clear"></div>
    </div>
    <div class="dld_options">
    <?php break;
    }
    }
    ?>
    <input type="hidden" name="action" value="save" />
    </form>
    <form method="post"><p class="submit"><input name="reset" type="submit" value="<?php _e("Reset", "dld_theme"); ?>" /><input type="hidden" name="action" value="reset" /></p></form>
    <div style="font-size:9px; margin-bottom:10px;">Theme by <a href="http://difluir.com">Difluir</a></div>
    </div>
    <?php }
    add_action('admin_init', 'dldtheme_add_init');
    add_action('admin_menu', 'dldtheme_add_admin');
    ?>
    Criador do tópico Lara C

    (@larissacas)

    Luci,

    tente colar o código antes de
    function blog_widgets_init() {

    E como vc quer deletar a cat 29, substitua o -10 por -29.

    =)

    Criador do tópico Lara C

    (@larissacas)

    oops, deletar não, omitir da página inicial.

    UHUUU!!

    Funcionou direitinho!

    MUITO OBRIGADA !

    e para excluir mais de 1 categoria? como seria o codigo na função?

    Criador do tópico Lara C

    (@larissacas)

    luhciano,

    não sei, mas tente assim:

    function my_query_posts_home($query){
    	if ($query->is_home){
    		$query->set('cat', '-ID CATEGORIA 1', '-ID CATEGORIA 2', E ASSIM POR DIANTE);
    	}
    	return $query;
    }
    add_filter('pre_get_posts','my_query_posts_home');

    se funcionar avisa, pode ser útil no futuro, ;D

Visualizando 14 respostas - 1 até 14 (de um total de 14)
  • O tópico ‘Excluir categoria APENAS da página principal.’ está fechado para novas respostas.