Fehler in Top3 Schlagzeilen!

Mona17

Grünschnabel
Guten Tag,

ich nutze WordPress und habe hier ein Codeschnipsel, der auch geht soweit.
Der erste Beitrag wird komplett angezeigt (im Admin Menü eingestellt das nur ein Beitrag auf der Index angezeigt werden soll, weil darunter ja dann die Top3), die weiteren sollen nur als Schlagzeile da stehen, aber das klappt nicht so ganz weil der erster Beitrag wird auch in den Top3 Schlagzeilen angezeigt!

PHP:
<?php
 $posts = get_posts('numberposts=3&category=1');
 foreach($posts as $post) :
 setup_postdata($post);
 ?>
<div class="post" id="post-<?php the_ID(); ?>">
                <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
                  </div>
 <?php endforeach; ?>

http://img19.imagevenue.com/img.php?image=03980_Zwischenablage02_123_783lo.jpg

Kann mir jemand helfen?
Danke sehr!"

eure Mona
 
Zuletzt bearbeitet:
PHP:
<?php
 $posts = get_posts('numberposts=3&category=1');
 $posts = array_shift($posts);
 foreach($posts as $post) :
 setup_postdata($post);
 ?>
<div class="post" id="post-<?php the_ID(); ?>">
                <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
                  </div>
 <?php endforeach; ?>

Probier es mal so.
[phpf]array_shift[/phpf] entfernt den ersten Eintrag eines Arrays.
 
Da habe ich Wordpress wohl ein wenig falsch eingeschätzt.

Könntest du mal folgendes einsetzen und das Ergebnis hier veröffentlichen?

(Ggf. sensible Daten entfernen)

PHP:
<?php
 $posts = get_posts('numberposts=3&category=1');
 echo "<pre>";
 print_r($posts);
 foreach($posts as $post) :
 setup_postdata($post);
 print_r($post);
 ?>
<div class="post" id="post-<?php the_ID(); ?>">
                <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
                  </div>
 <?php endforeach; ?>
echo "</pre>";
 
Hallo,

es ist folgender komischer Text bei rausgekommen!

PHP:
Array
(
    [0] => stdClass Object
        (
            [ID] => 16
            [post_author] => 1
            [post_date] => 2007-05-03 13:03:00
            [post_date_gmt] => 2007-05-03 11:03:00
            [post_content] => 

Ut consectetuer, nunc at porttitor venenatis, ligula massa tristique tortor, eget volutpat tellus tortor ac arcu. Ut elit lectus, blandit at, consectetuer vitae, tincidunt eget, sapien. Ut facilisis, mi et tincidunt bibendum, ante arcu egestas diam, vitae egestas est quam sit amet orci. Ut felis justo, laoreet a, consequat non, porta pretium, massa. Ut felis leo, tempor eu, condimentum nec, vehicula at, nulla.

Curabitur libero purus, adipiscing at, nonummy non, aliquet quis, metus. Curabitur ligula est, mattis sed, pulvinar quis, euismod at, erat. Curabitur massa massa, vestibulum id, volutpat id, semper id, eros. Curabitur mattis, pede eget interdum volutpat, purus mauris dignissim arcu, ut viverra erat arcu non mi. Curabitur neque nunc, vestibulum quis, ultrices cursus, iaculis id, velit.

Curabitur nunc ipsum, fermentum in, faucibus quis, facilisis a, turpis. Curabitur sem odio, tincidunt quis, hendrerit sed, facilisis a, risus. Curabitur tellus justo, convallis fringilla, congue nec, malesuada ut, wisi. Curabitur tellus magna, porta a, pulvinar non, ultrices in, orci. Curabitur turpis arcu, mattis vehicula, lobortis sit amet, dignissim ac, massa.

Donec odio nunc, fringilla id, adipiscing eu, interdum sed, odio. Donec pede nunc, dictum sit amet, posuere nec, venenatis sed, nibh. Donec porttitor, ipsum quis feugiat fringilla, velit ligula suscipit ante, sit amet pharetra dui sapien non augue. Donec risus dui, venenatis at, commodo a, lobortis at, tellus. Donec sapien est, imperdiet eget, vestibulum at, cursus nec, velit.

Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nullam lacinia, felis viverra elementum viverra, massa urna feugiat diam, nec dictum lacus felis ac est.

            [post_title] => 7ter
            [post_category] => 0
            [post_excerpt] => 
            [post_status] => publish
            [comment_status] => open
            [ping_status] => open
            [post_password] => 
            [post_name] => 7ter
            [to_ping] => 
            [pinged] => 
            [post_modified] => 2007-05-03 13:03:00
            [post_modified_gmt] => 2007-05-03 11:03:00
            [post_content_filtered] => 
            [post_parent] => 0
            [guid] => http://***.de/?p=16
            [menu_order] => 0
            [post_type] => post
            [post_mime_type] => 
            [comment_count] => 0
            [rel_id] => 17
            [post_id] => 16
            [category_id] => 1
        )

    [1] => stdClass Object
        (
            [ID] => 10
            [post_author] => 1
            [post_date] => 2007-05-03 12:34:28
            [post_date_gmt] => 2007-05-03 10:34:28
            [post_content] => Ut consectetuer, nunc at porttitor venenatis, ligula massa tristique tortor, eget volutpat tellus tortor ac arcu. Ut elit lectus, blandit at, consectetuer vitae, tincidunt eget, sapien. Ut facilisis, mi et tincidunt bibendum, ante arcu egestas diam, vitae egestas est quam sit amet orci. Ut felis justo, laoreet a, consequat non, porta pretium, massa. Ut felis leo, tempor eu, condimentum nec, vehicula at, nulla.



Curabitur libero purus, adipiscing at, nonummy non, aliquet quis, metus. Curabitur ligula est, mattis sed, pulvinar quis, euismod at, erat. Curabitur massa massa, vestibulum id, volutpat id, semper id, eros. Curabitur mattis, pede eget interdum volutpat, purus mauris dignissim arcu, ut viverra erat arcu non mi. Curabitur neque nunc, vestibulum quis, ultrices cursus, iaculis id, velit.

Curabitur nunc ipsum, fermentum in, faucibus quis, facilisis a, turpis. Curabitur sem odio, tincidunt quis, hendrerit sed, facilisis a, risus. Curabitur tellus justo, convallis fringilla, congue nec, malesuada ut, wisi. Curabitur tellus magna, porta a, pulvinar non, ultrices in, orci. Curabitur turpis arcu, mattis vehicula, lobortis sit amet, dignissim ac, massa.

Donec odio nunc, fringilla id, adipiscing eu, interdum sed, odio. Donec pede nunc, dictum sit amet, posuere nec, venenatis sed, nibh. Donec porttitor, ipsum quis feugiat fringilla, velit ligula suscipit ante, sit amet pharetra dui sapien non augue. Donec risus dui, venenatis at, commodo a, lobortis at, tellus. Donec sapien est, imperdiet eget, vestibulum at, cursus nec, velit.
            [post_title] => huhuhu hahahah
            [post_category] => 0
            [post_excerpt] => 
            [post_status] => publish
            [comment_status] => open
            [ping_status] => open
            [post_password] => 
            [post_name] => huhuhu-hahahah
            [to_ping] => 
            [pinged] => 
            [post_modified] => 2007-05-03 12:34:28
            [post_modified_gmt] => 2007-05-03 10:34:28
            [post_content_filtered] => 
            [post_parent] => 0
            [guid] => http://***de/?p=10
            [menu_order] => 0
            [post_type] => post
            [post_mime_type] => 
            [comment_count] => 1
            [rel_id] => 11
            [post_id] => 10
            [category_id] => 1
        )

    [2] => stdClass Object
        (
            [ID] => 9
            [post_author] => 1
            [post_date] => 2007-05-03 12:32:42
            [post_date_gmt] => 2007-05-03 10:32:42
            [post_content] => 

Ut consectetuer, nunc at porttitor venenatis, ligula massa tristique tortor, eget volutpat tellus tortor ac arcu. Ut elit lectus, blandit at, consectetuer vitae, tincidunt eget, sapien. Ut facilisis, mi et tincidunt bibendum, ante arcu egestas diam, vitae egestas est quam sit amet orci. Ut felis justo, laoreet a, consequat non, porta pretium, massa. Ut felis leo, tempor eu, condimentum nec, vehicula at, nulla.

Curabitur libero purus, adipiscing at, nonummy non, aliquet quis, metus. Curabitur ligula est, mattis sed, pulvinar quis, euismod at, erat. Curabitur massa massa, vestibulum id, volutpat id, semper id, eros. Curabitur mattis, pede eget interdum volutpat, purus mauris dignissim arcu, ut viverra erat arcu non mi. Curabitur neque nunc, vestibulum quis, ultrices cursus, iaculis id, velit.

Curabitur nunc ipsum, fermentum in, faucibus quis, facilisis a, turpis. Curabitur sem odio, tincidunt quis, hendrerit sed, facilisis a, risus. Curabitur tellus justo, convallis fringilla, congue nec, malesuada ut, wisi. Curabitur tellus magna, porta a, pulvinar non, ultrices in, orci. Curabitur turpis arcu, mattis vehicula, lobortis sit amet, dignissim ac, massa.



Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nullam lacinia, felis viverra elementum viverra, massa urna feugiat diam, nec dictum lacus felis ac est.

            [post_title] => Ohne fünften kein Blog!
            [post_category] => 0
            [post_excerpt] => 
            [post_status] => publish
            [comment_status] => open
            [ping_status] => open
            [post_password] => 
            [post_name] => ohne-funften-kein-blog
            [to_ping] => 
            [pinged] => 
            [post_modified] => 2007-05-03 12:32:42
            [post_modified_gmt] => 2007-05-03 10:32:42
            [post_content_filtered] => 
            [post_parent] => 0
            [guid] => http://***.de/?p=9
            [menu_order] => 0
            [post_type] => post
            [post_mime_type] => 
            [comment_count] => 2
            [rel_id] => 10
            [post_id] => 9
            [category_id] => 1
        )

)
stdClass Object
(
    [ID] => 16
    [post_author] => 1
    [post_date] => 2007-05-03 13:03:00
    [post_date_gmt] => 2007-05-03 11:03:00
    [post_content] => 

Ut consectetuer, nunc at porttitor venenatis, ligula massa tristique tortor, eget volutpat tellus tortor ac arcu. Ut elit lectus, blandit at, consectetuer vitae, tincidunt eget, sapien. Ut facilisis, mi et tincidunt bibendum, ante arcu egestas diam, vitae egestas est quam sit amet orci. Ut felis justo, laoreet a, consequat non, porta pretium, massa. Ut felis leo, tempor eu, condimentum nec, vehicula at, nulla.

Curabitur libero purus, adipiscing at, nonummy non, aliquet quis, metus. Curabitur ligula est, mattis sed, pulvinar quis, euismod at, erat. Curabitur massa massa, vestibulum id, volutpat id, semper id, eros. Curabitur mattis, pede eget interdum volutpat, purus mauris dignissim arcu, ut viverra erat arcu non mi. Curabitur neque nunc, vestibulum quis, ultrices cursus, iaculis id, velit.

Curabitur nunc ipsum, fermentum in, faucibus quis, facilisis a, turpis. Curabitur sem odio, tincidunt quis, hendrerit sed, facilisis a, risus. Curabitur tellus justo, convallis fringilla, congue nec, malesuada ut, wisi. Curabitur tellus magna, porta a, pulvinar non, ultrices in, orci. Curabitur turpis arcu, mattis vehicula, lobortis sit amet, dignissim ac, massa.

Donec odio nunc, fringilla id, adipiscing eu, interdum sed, odio. Donec pede nunc, dictum sit amet, posuere nec, venenatis sed, nibh. Donec porttitor, ipsum quis feugiat fringilla, velit ligula suscipit ante, sit amet pharetra dui sapien non augue. Donec risus dui, venenatis at, commodo a, lobortis at, tellus. Donec sapien est, imperdiet eget, vestibulum at, cursus nec, velit.

Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nullam lacinia, felis viverra elementum viverra, massa urna feugiat diam, nec dictum lacus felis ac est.

    [post_title] => 7ter
    [post_category] => 0
    [post_excerpt] => 
    [post_status] => publish
    [comment_status] => open
    [ping_status] => open
    [post_password] => 
    [post_name] => 7ter
    [to_ping] => 
    [pinged] => 
    [post_modified] => 2007-05-03 13:03:00
    [post_modified_gmt] => 2007-05-03 11:03:00
    [post_content_filtered] => 
    [post_parent] => 0
    [guid] => http://***.de/?p=16
    [menu_order] => 0
    [post_type] => post
    [post_mime_type] => 
    [comment_count] => 0
    [rel_id] => 17
    [post_id] => 16
    [category_id] => 1
)
7ter

 stdClass Object
(
    [ID] => 10
    [post_author] => 1
    [post_date] => 2007-05-03 12:34:28
    [post_date_gmt] => 2007-05-03 10:34:28
    [post_content] => Ut consectetuer, nunc at porttitor venenatis, ligula massa tristique tortor, eget volutpat tellus tortor ac arcu. Ut elit lectus, blandit at, consectetuer vitae, tincidunt eget, sapien. Ut facilisis, mi et tincidunt bibendum, ante arcu egestas diam, vitae egestas est quam sit amet orci. Ut felis justo, laoreet a, consequat non, porta pretium, massa. Ut felis leo, tempor eu, condimentum nec, vehicula at, nulla.



Curabitur libero purus, adipiscing at, nonummy non, aliquet quis, metus. Curabitur ligula est, mattis sed, pulvinar quis, euismod at, erat. Curabitur massa massa, vestibulum id, volutpat id, semper id, eros. Curabitur mattis, pede eget interdum volutpat, purus mauris dignissim arcu, ut viverra erat arcu non mi. Curabitur neque nunc, vestibulum quis, ultrices cursus, iaculis id, velit.

Curabitur nunc ipsum, fermentum in, faucibus quis, facilisis a, turpis. Curabitur sem odio, tincidunt quis, hendrerit sed, facilisis a, risus. Curabitur tellus justo, convallis fringilla, congue nec, malesuada ut, wisi. Curabitur tellus magna, porta a, pulvinar non, ultrices in, orci. Curabitur turpis arcu, mattis vehicula, lobortis sit amet, dignissim ac, massa.

Donec odio nunc, fringilla id, adipiscing eu, interdum sed, odio. Donec pede nunc, dictum sit amet, posuere nec, venenatis sed, nibh. Donec porttitor, ipsum quis feugiat fringilla, velit ligula suscipit ante, sit amet pharetra dui sapien non augue. Donec risus dui, venenatis at, commodo a, lobortis at, tellus. Donec sapien est, imperdiet eget, vestibulum at, cursus nec, velit.
    [post_title] => huhuhu hahahah
    [post_category] => 0
    [post_excerpt] => 
    [post_status] => publish
    [comment_status] => open
    [ping_status] => open
    [post_password] => 
    [post_name] => huhuhu-hahahah
    [to_ping] => 
    [pinged] => 
    [post_modified] => 2007-05-03 12:34:28
    [post_modified_gmt] => 2007-05-03 10:34:28
    [post_content_filtered] => 
    [post_parent] => 0
    [guid] => http://***.de/?p=10
    [menu_order] => 0
    [post_type] => post
    [post_mime_type] => 
    [comment_count] => 1
    [rel_id] => 11
    [post_id] => 10
    [category_id] => 1
)
huhuhu hahahah

 stdClass Object
(
    [ID] => 9
    [post_author] => 1
    [post_date] => 2007-05-03 12:32:42
    [post_date_gmt] => 2007-05-03 10:32:42
    [post_content] => 

Ut consectetuer, nunc at porttitor venenatis, ligula massa tristique tortor, eget volutpat tellus tortor ac arcu. Ut elit lectus, blandit at, consectetuer vitae, tincidunt eget, sapien. Ut facilisis, mi et tincidunt bibendum, ante arcu egestas diam, vitae egestas est quam sit amet orci. Ut felis justo, laoreet a, consequat non, porta pretium, massa. Ut felis leo, tempor eu, condimentum nec, vehicula at, nulla.

Curabitur libero purus, adipiscing at, nonummy non, aliquet quis, metus. Curabitur ligula est, mattis sed, pulvinar quis, euismod at, erat. Curabitur massa massa, vestibulum id, volutpat id, semper id, eros. Curabitur mattis, pede eget interdum volutpat, purus mauris dignissim arcu, ut viverra erat arcu non mi. Curabitur neque nunc, vestibulum quis, ultrices cursus, iaculis id, velit.

Curabitur nunc ipsum, fermentum in, faucibus quis, facilisis a, turpis. Curabitur sem odio, tincidunt quis, hendrerit sed, facilisis a, risus. Curabitur tellus justo, convallis fringilla, congue nec, malesuada ut, wisi. Curabitur tellus magna, porta a, pulvinar non, ultrices in, orci. Curabitur turpis arcu, mattis vehicula, lobortis sit amet, dignissim ac, massa.



Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nullam lacinia, felis viverra elementum viverra, massa urna feugiat diam, nec dictum lacus felis ac est.

    [post_title] => Ohne fünften kein Blog!
    [post_category] => 0
    [post_excerpt] => 
    [post_status] => publish
    [comment_status] => open
    [ping_status] => open
    [post_password] => 
    [post_name] => ohne-funften-kein-blog
    [to_ping] => 
    [pinged] => 
    [post_modified] => 2007-05-03 12:32:42
    [post_modified_gmt] => 2007-05-03 10:32:42
    [post_content_filtered] => 
    [post_parent] => 0
    [guid] => http://***.de/?p=9
    [menu_order] => 0
    [post_type] => post
    [post_mime_type] => 
    [comment_count] => 2
    [rel_id] => 10
    [post_id] => 9
    [category_id] => 1
)
Ohne fünften kein Blog!

 echo "

";

Naja, Frauen können wohl doch nur Kochen :)
Bist sehr nett! Tolles Forum!
 
Sorry, mein Fehler. Das kommt davon, wenn man nicht aufpasst.

PHP:
<?php
 $posts = get_posts('numberposts=3&category=1');
 $trash = array_shift($posts);
 foreach($posts as $post) :
 setup_postdata($post);
 ?>
<div class="post" id="post-<?php the_ID(); ?>">
                <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
                  </div>
 <?php endforeach; ?>

Versuch es einmal so.
 
Wow!
Es hat geklappt!
Das einzige was man noch ändern muss, ist dann die Zahl der Beiträge.

('numberposts=3&category=1');
Bei 3 werden nur 2 angezeigt, weil der erste ja irgendwie ausgelesen wird, also muss man 4 eingeben damit 3 angezeigt werden!! siehste ich bin auch bisschen schlau :-)

Danke Dir! Du bist super!

bussy

gruß,
mona
 
Gern geschehen.

Jetzt noch auf "Erledigt" klicken (unten, neben "Antworten") und die Welt ist wieder in Ordnung.
 
Ist Erledigt :)
Wenn ich fragen hab, dann suche ich einfach nach Felix :)

Edit: eine Frage habe ich noch! Ich habe gerade bemerkt, dass wenn ich auf der Index nur 1 Beitrag anzeigen lasse, dass ich dies auch dann in den Kategorien habe, wobei dort min. 5-7 Beiträge angezeigt werden sollen, nur irgendwie lässt sich das nur durch das Admin Menü ändern betreffend auf alle Seiten :(
Wie schließt man die neusten X Beiträge aus dem Code aus?
 
Zuletzt bearbeitet:
Zurück