Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> (WP)Problem z pętlą
WujekWladek
post
Post #1





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 30.01.2016

Ostrzeżenie: (0%)
-----


Witam
Mam problem z wyświetlaniem postów z tylko jednej kategorii.
A pokazują się posty z innych kategorii.
Kategoria ma id 2.
Strona jest na wordpress
  1. <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
  2. <?php if ( is_category( "2" ) ) : ?>
  3. <div class="post-cat-three">
  4. <?php else : ?>
  5. <div class="post">
  6. <?php endif; ?>
  7. <!-- Display the Title as a link to the Post's permalink. -->
  8. <h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
  9. <!-- Display the date (November 16th, 2009 format) and a link to other posts by this posts author. -->
  10. <small><?php the_time('F jS, Y'); ?> by <?php the_author_posts_link(); ?></small>
  11. <!-- Display the Post's content in a div box. -->
  12. <div class="entry">
  13. <?php the_content(); ?>
  14. </div>
  15. <!-- Display a comma separated list of the Post's Categories. -->
  16. <p class="postmetadata"><?php _e( 'Posted in' ); ?> <?php the_category( ', ' ); ?></p>
  17. </div> <!-- closes the first div box -->
  18. <!-- Stop The Loop (but note the "else:" - see next line). -->
  19. <?php endwhile; else : ?>
  20. <!-- The very first "if" tested to see if there were any Posts to -->
  21. <!-- display. This "else" part tells what do if there weren't any. -->
  22. <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
  23. <!-- REALLY stop The Loop. -->
  24. <?php endif; ?>


Pomoże ktoś ? worriedsmiley.gif worriedsmiley.gif
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 5)
Malukaz
post
Post #2





Grupa: Zarejestrowani
Postów: 77
Pomógł: 4
Dołączył: 16.04.2009

Ostrzeżenie: (10%)
X----


a masz wogole posty w kategorii 2 ?

pokaż co zwraca:

var_dump(have_posts());

Ten post edytował Malukaz 30.01.2016, 16:04:39
Go to the top of the page
+Quote Post
WujekWladek
post
Post #3





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 30.01.2016

Ostrzeżenie: (0%)
-----


D:\yf\motyw\wp-content\themes\daniela\index.php:49:boolean true
Go to the top of the page
+Quote Post
WujekWladek
post
Post #4





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 30.01.2016

Ostrzeżenie: (0%)
-----


D:\yf\motyw\wp-content\themes\daniela\index.php:49:boolean true
Go to the top of the page
+Quote Post
Malukaz
post
Post #5





Grupa: Zarejestrowani
Postów: 77
Pomógł: 4
Dołączył: 16.04.2009

Ostrzeżenie: (10%)
X----


magiczne funkcje wordpressowe omg...

co mowi dokumentacja wp o funkcji is_category( "2" ) ?

i powtarzam skad wiesz ze masz posty w kategorii 2 wogole ?
Go to the top of the page
+Quote Post
WujekWladek
post
Post #6





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 30.01.2016

Ostrzeżenie: (0%)
-----


Mam 6 wpisów w tej kategorii.
I kilka bez kategorii.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 08:31