is category page.

Plugin-uri, teme, configurare

Moderator: Moderatori

teodor98
Average Member
Mesaje: 98
Membru din: Mar Iul 17, 2012 7:08 pm
Contact:

is category page.

Mesajde teodor98 » Sâm Ian 12, 2013 12:27 am

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)?



Avatar utilizator
morjanmihail
Junior Member
Mesaje: 33
Membru din: Dum Dec 30, 2012 11:04 am
Localitate: Timisoara
Contact:

Re: is category page.

Mesajde morjanmihail » Sâm Ian 12, 2013 2:38 pm

Daca vrei sa iei posturile dintr-o categorie folosesti:

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.
Web Designer & Developer. Website-uri personale:
- http://softeam.ro
- http://morjanmihail.info

teodor98
Average Member
Mesaje: 98
Membru din: Mar Iul 17, 2012 7:08 pm
Contact:

Re: is category page.

Mesajde teodor98 » Sâm Ian 26, 2013 6:01 pm

Mersi am rezolvat problema .


Înapoi la “Wordpress”

Cine este conectat

Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 3 vizitatori