Visualizza le categorie dal tipo di post personalizzato
-
-
Maperché duetassonomie di categorie diverse?Hai latassonomiapersonalizzata `portfolio-category` registrata,main aggiunta stai abilitando lanormaletassonomia delle categorieper questotipo dipost,ades.`'taxonomy'=> array ('category','post_tag')`,ti servonoentrambi?Why two different category taxonomies though? You have the custom `portfolio-category` taxonomy registered, but additionally you're enabling the regular category taxonomy for this post type to, eg. `'taxonomy' => array('category', 'post_tag')`, do you need both?
- 0
- 2011-02-18
- t31os
-
Sì,hobisogno dientrambe le categorieperché desidero aggiungerei dettagli delportfolio allemie categorie diportfolioe non vogliomostrare le categorie delportfolio sulblog oin altreparti del sito.Eccoperché sto usando due categorie.Yes I need both categories as I want to add portfolio details to my portfolio categories and dont want to show portfolio categories on blog or some where else on site. Thats why I am using two categories.
-
2 risposta
- voti
-
- 2011-02-18
Che dire dell'utilizzo di get_terms () ?
Esempio rapido:
$terms = get_terms('portfolio-category'); foreach ( $terms as $term ) { echo $term->name.'<br />'; }
What about using get_terms()?
Quick example:
$terms = get_terms('portfolio-category'); foreach ( $terms as $term ) { echo $term->name.'<br />'; }
-
- 2011-02-18
per ottenerei post deltuotipo dipostpersonalizzato deviinterrogarepost_typee puoifarloin questomodo:
<?php query_posts(array( 'post_type' => 'Portfolio' )); ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div class="post"> <!-- Display the Title as a link to the Post's permalink. --> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <!-- Display the date (November 16th, 2009 format) and a link to other posts by this posts author. --> <small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small> <div class="entry"> <?php the_content(); ?> </div> <p class="postmetadata">Posted in <?php the_category(', '); ?></p> </div> <!-- closes the first div box --> <?php endwhile; else: ?> <p>Sorry, no posts matched your criteria.</p> <?php endif; ?>
Ora,se desideri ottenere unpostnel Portfolio di untermine specificonellatuataxonamypersonalizzato quindi aggiungi l'argomentotassonomia all'array query_postsin questomodo:
<?php query_posts(array( 'post_type' => 'Portfolio','portfolio-category' => 'category-name' )); ?>
Spero che questo aiuti.
to get the posts of your custom post type you need to query post_type and you can do it like so:
<?php query_posts(array( 'post_type' => 'Portfolio' )); ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div class="post"> <!-- Display the Title as a link to the Post's permalink. --> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <!-- Display the date (November 16th, 2009 format) and a link to other posts by this posts author. --> <small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small> <div class="entry"> <?php the_content(); ?> </div> <p class="postmetadata">Posted in <?php the_category(', '); ?></p> </div> <!-- closes the first div box --> <?php endwhile; else: ?> <p>Sorry, no posts matched your criteria.</p> <?php endif; ?>
Now if you want to get Portfolio post of a specific term in your custom taxonamy then add the taxonomy argument to the query_posts array like so:
<?php query_posts(array( 'post_type' => 'Portfolio','portfolio-category' => 'category-name' )); ?>
Hope this helps.
Ho creatoiltipo dipostpersonalizzato "Portfolio" anche sotto questotipo dipost ho creato categorie di Portfolio conil seguente codice
functions.php - di seguito è riportatoil codiceperiltipo dipostpersonalizzato che ho definitonellapaginafunctions.php
Ora voglio recuperaretutte le categorie da questotipo diposte visualizzarei post dalle categorie sullapagina?
Fammi sapere comepossofarlo?
Grazie.