is category page.
Moderator: Moderatori
is category page.
Exista o faunctie de wordpress ca is_home().Pentru a verifica daca pagina respectiva este o pagina de categorie(adica unde sunt aratate toate articolele din categorie)?
- morjanmihail
- Junior Member
- Mesaje: 33
- Membru din: Dum Dec 30, 2012 11:04 am
- Localitate: Timisoara
- Contact:
Re: is category page.
Daca vrei sa iei posturile dintr-o categorie folosesti:
Cu un search pe google rezolvai usor. Uite un fragment care te poate interesa:
Cod: Selectaţi tot
query_posts(&query_string.'&cat=5'); // afiseaza posturile categoriei 5
Cu un search pe google rezolvai usor. Uite un fragment care te poate interesa:
Cod: Selectaţi tot
Next, we need to add a query to our loop that will extract only those posts that belong to the Featured category, that is, to those posts that belong to the category with the ID of 9. Follow these steps:
1. Open the file that contains the loop. We'll use the same file we created in the preceding recipe.
2. Find the loop:
3. <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
4. <h2><?php the_title() ?></h2>
5. <?php the_author_posts_link() ?>
6. <div class="thecontent">
7. <?php the_content(); ?>
8. </div>
9. <?php endwhile; else: ?>
10. <p>Oops! There are no posts to display.</p>
11. <?php endif; ?>
12. Add the following line of code immediately above the loop:
13. <?php query_posts($query_string.'&cat=9'); ?>
14. Save the file.
That's all there is to it. If you visit your site, you will now see that the page displays only the posts that belong to the category with the ID of 9.
How it works...
The query_posts() function modifies the default loop. When used with the cat parameter, it allows you to specify one or more categories that you want to use as filters for the posts.
Re: is category page.
Mersi am rezolvat problema .
Cine este conectat
Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 3 vizitatori