Sorry, aber wo jetzt ?
Beiträge von stevie99
-
-
Sorry, aber wo jetzt ?
-
Achso, mann bin ich schon durcheinanader.
Sorry, bringt leider auch nix
Und nu ? -
Das wäre aber ja falsch, denn in der Einzelansicht muss er ja ganz angezeigt werden.
Ausschliesslich in der Vorschau soll er gekürzt sein. Überall anders ganz angezeigt werden -
das passiert:
Parse error: syntax error, unexpected '*' in /home/www/web44/html/wp-content/plugins/limit_post.php on line 23 -
ja...natürlich sind alle größer als 400 Zeichen !
-
Hallo, wir können es auch ohne plugin machen, (wäre mir sogar lieber) wenn Du weisst wie es geht.
Das Plugin heisst: "Limit Posts" und sein Code sieht so aus:
PHP
Alles anzeigen<?php /* Plugin Name: Limit Posts Plugin URI: http://labitacora.net/comunBlog/limit-post.phps Description: Limits the displayed text length on the index page entries and generates a link to a page to read the full content if its bigger than the selected maximum length. Usage: the_content_limit($max_charaters, $more_link) Version: 1.1 Author: Alfonso Sanchez-Paus Diaz y Julian Simon de Castro Author URI: http://labitacora.net/ License: GPL Download URL: http://labitacora.net/comunBlog/limit-post.phps Make: In file index.php replace the_content() with the_content_limit(1000, "more") */ function the_content_limit($max_char, $more_link_text = '(more...)', $stripteaser = 0, $more_file = '') { $content = get_the_content($more_link_text, $stripteaser, $more_file); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); if (strlen($_GET['p']) > 0) { echo $content; } else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) { $content = substr($content, 0, $espacio); $content = $content; echo $content; echo "<a href='"; the_permalink(); echo "'>"."..."."</a>"; echo "<a href='"; the_permalink(); echo "'>".$more_link_text."</a></p>"; } else { echo $content; } } ?> -
Ich füge auf meiner Startseite 4 Postings aus einer Kategorie ein.
Jetzt würde ich gerne unter jedem dieser 4 Postings die Überschriften von zwei älteren Artikeln anzeigen.
Und zwar so:
Posting 1 (letztes Posting): Die letzten Postings 5 und 6
Posting 2 (vorletztes Posting): Die letzten Postings 7 und 8
Posting 4 (vorvorletztes Posting): Die letzten Postings 9 und 10Geht das und wenn ja wie ?
-
Also: Der Code ist jetzt so und läuft:
PHP
Alles anzeigen<?php get_header(); ?> <div id="content" class="narrowcolumn"> <?php query_posts('cat=13&showposts=4'); ?> <div class="kategorie-start">Boulevard</div> <div class="cats"> <?php while (have_posts()) : the_post(); ?> <div class="entry"> <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> <?php the_content_limit(400, "mehr...");?> </div><!--entry end--> <?php endwhile; ?> </div><!--cats end--> <?php query_posts('cat=14&showposts=3'); ?> <div class="kategorie-start">Boulevard</div> <div class="cats"> <?php while (have_posts()) : the_post(); ?> <div class="entry"> <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> <?php the_content_limit(400, "mehr...");?> </div><!--entry end--> <?php endwhile; ?> </div><!--cats end--> <div class="navigation"> <div class="alignleft"><?php next_posts_link('« Vorherige Einträge') ?></div> <div class="alignright"><?php previous_posts_link('Nächste Einträge »') ?></div> </div><!--navigation end--> </div><!--content end--> <?php get_sidebar(); ?> <?php get_footer(); ?>Was sagst Du dazu ? :-D
Nun aber noch eine kleine Frage:
Dieser Teil:
Wir im Moment nur auf das jeweils erste Posting angewendet. Es muss aber natürlich für alle Relevaant sein (Es handelt sich um die Zeichenbegrenzung)
Weisst Du warum bzw. was ich ändern muss ?
-
Ich denke Du siehst das falsch Marx. Ich beschäftige mich sehr mit dem was Du schreibst und probieren tu ich den ganzen Tag:)
Aber mal so rein grundsätzlich:
Ziel bei mir ist, aus verschiedenen Kategorien eine bestimmte Anzahl an Beiträgen auf der Startseite ausgeben zu lassen.
Also von Kategorie 1, 4 Stück
Kategorie 2, 3 Stück
Kategroie 3, 3 Stück
Kategorie 4, 3 Stück.Jede dieser Kategorien hat von mir eine Überschrift bekommen, die ich mit einer Klasse versehen habe.
Dieser Code heisst:
<div class="kategorie-start">Boulevard</div>
Weiterhin versehe ich jeden ausgegebenen Artikel mit einem Permalink und begrenze die Zeichenanzahl mit einem Plugin.
Das mache ich so:
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<?php the_content_limit(400, "mehr...");?>So weit alles gut und das funktioniert auch wunderbar.
Nun aber gibt es eben noch das Problem mit dem Einfügen der Kategorien, Ist das, von was wir die ganze Zeit sprechen, für meine Aufgabenstellung denn überhaupt die richtige und einfachste Variante oder gibt es etwas Besseres ?
Wenn nicht, dann müsste der vorherige Code von Dir doch gehen, oder ?
-
Danke, aber so ist das ganze Design zerschossen.
So funktioniert der Code leider nicht -
Oh shit. Jetzt ist das schon wieder passiert. Ich versuche, dass es nicht mehr vorkommt. Entschuldigung !
Kannst Du mir mal bitte sagen, wie so ein Code dann aussehen müsste ?
Ach ja und funktioniert es auch ohne diese Abfrage, ob Beiträge da sind ? -
Also wenn och den Code zweimalhintereinander eingegeben habe, wie folgt:
PHP
Alles anzeigen<?php get_header(); ?> <div id="content" class="narrowcolumn"> <?php query_posts('cat=14&showposts=3'); ?> <?php if (have_posts()) : ?> <div class="kategorie-start">Boulevard</div> <div class="entry"> <div class="cats"> <?php while (have_posts()) : the_post(); ?> <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> <?php the_content_limit(400, "mehr...");?> </div> </div> <?php endwhile; ?> <div id="content" class="narrowcolumn"> <?php query_posts('cat=14&showposts=3'); ?> <?php if (have_posts()) : ?> <div class="kategorie-start">Boulevard</div> <div class="entry"> <div class="cats"> <?php while (have_posts()) : the_post(); ?> <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> <?php the_content_limit(400, "mehr...");?> </div> </div> <?php endwhile; ?> <div class="navigation"> <div class="alignleft"><?php next_posts_link('« Vorherige Einträge') ?></div> <div class="alignright"><?php previous_posts_link('Nächste Einträge »') ?></div> </div> <?php else : ?> <h2 class="center">Nicht gefunden</h2> <p class="center">Sorry, aber du suchst gerade nach etwas, was hier nicht ist.</p> <?php include (TEMPLATEPATH . "/searchform.php"); ?> <?php endif; ?> </div> <?php get_sidebar(); ?> <?php get_footer(); ?>dann erhalte ich die folgende Fehlermeldung:
Parse error: syntax error, unexpected $end in /home/www/web44/html/wp-content/themes/default_de/index.php on line 56
Gebe ich ihn aber ein so wie ich ihn hier hatte:
[COLOR=#000000]<div id="content" class="narrowcolumn">
[COLOR=#0000cc]<?php [/COLOR][COLOR=#006600]if ([/COLOR][COLOR=#0000cc]have_posts[/COLOR][COLOR=#006600]()) : [/COLOR][COLOR=#0000cc]?>
[/COLOR]
<div class="kategorie-start">Boulevard</div>
<div class="entry">
<div id="cats">
[COLOR=#0000cc]<?php query_posts[/COLOR][COLOR=#006600]([/COLOR][COLOR=#cc0000]'cat=14&showposts=3'[/COLOR][COLOR=#006600]); [/COLOR][COLOR=#0000cc]?>[/COLOR]
[COLOR=#0000cc]<?php [/COLOR][COLOR=#006600]while ([/COLOR][COLOR=#0000cc]have_posts[/COLOR][COLOR=#006600]()) : [/COLOR][COLOR=#0000cc]the_post[/COLOR][COLOR=#006600](); [/COLOR][COLOR=#0000cc]?>
[/COLOR]<h2><a href="[COLOR=#0000cc]<?php the_permalink[/COLOR][COLOR=#006600]() [/COLOR][COLOR=#0000cc]?>[/COLOR]">[COLOR=#0000cc]<?php the_title[/COLOR][COLOR=#006600](); [/COLOR][COLOR=#0000cc]?>[/COLOR]</a></h2> [COLOR=#0000cc]<?php the_content_limit[/COLOR][COLOR=#006600]([/COLOR][COLOR=#0000cc]400[/COLOR][COLOR=#006600], [/COLOR][COLOR=#cc0000]"mehr..."[/COLOR][COLOR=#006600]);[/COLOR][COLOR=#0000cc]?>
[/COLOR]
</div>
</div> [/COLOR]dann geht es
oder wenn ich das [COLOR=#000000][COLOR=#0000cc]<?php [/COLOR][COLOR=#006600]if ([/COLOR][COLOR=#0000cc]have_posts[/COLOR][COLOR=#006600]()) : [/COLOR][COLOR=#0000cc]?> weglasse[/COLOR][/COLOR], dann geht es auch.
P.S.: Es ist sichergestellt, dass es in jeder Kategorie immer Posts gibt !
-
Wenn ich einen Cat reinbaue geht es.
Bei mehreren steigt der Server aus. Wieso ??
PHP
Alles anzeigen<?php get_header(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <meta name="generator" content="HTML Tidy for Linux (vers 1 September 2005), see www.w3.org"> <title></title> <style type="text/css"> a.c1 {color:#c00} </style> </head> <body> <div id="content" class="narrowcolumn"> <?php query_posts('cat=14&showposts=3'); ?> <?php if (have_posts()) : ?> <div class="kategorie-start">Boulevard</div> <div class="entry"> <div class="cats"> <?php while (have_posts()) : the_post(); ?> <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> <?php the_content_limit(400, "mehr...");?> </div> </div> <?php endwhile; ?> <?php query_posts('cat=12&showposts=3'); ?> <?php if (have_posts()) : ?> <div class="kategorie-start">Boulevard</div> <div class="entry"> <div class="cats"> <?php while (have_posts()) : the_post(); ?> <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> <?php the_content_limit(400, "mehr...");?> </div> </div> <?php endwhile; ?> <div class="navigation"> <div class="alignleft"><?php next_posts_link('« Vorherige Einträge') ?></div> <div class="alignright"><?php previous_posts_link('Nächste Einträge »') ?></div> </div> <?php else : ?> <h2 class="center">Nicht gefunden</h2> <p class="center">Sorry, aber du suchst gerade nach etwas, was hier nicht ist.</p> <?php include (TEMPLATEPATH . "/searchform.php"); ?> <?php endif; ?> </div> <?php get_sidebar(); ?> <?php get_footer(); ?> </body> </html>P.S.: So wie ich es oben in dem Code hatte haben mehrere untereinander funktioniert komischer Weise
-
Hallo,
gibt es eine Möglichkeit oder gar ein Plugin, ähnliche Artikel anzuzeigen ?
Von den Artikeln würde die Überschrift reichen.Mit "ähnlich" meine ich thematisch ähnlich (was ja wohl schwierig umsetzbar ist), somit also der Überschrift bzw. den darin enthaltenen Worten ähnlich
-
Ok, vielen Dank, hat geklappt !
jottlieb, sorry war keine Absicht !
-
Ok...also so: ????
PHP
Alles anzeigen</head> <body> <div id="content" class="narrowcolumn"> <?php if (have_posts()) : ?> <div class="kategorie-start">Boulevard</div> <div class="entry"> <div id="cats"> <?php query_posts('cat=14&showposts=3'); ?> <?php while (have_posts()) : the_post(); ?> <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> <?php the_content_limit(400, "mehr...");?> </div> </div> <?php endwhile; ?> <div class="navigation"> <div class="alignleft"><?php next_posts_link('« Vorherige Einträge') ?></div> <div class="alignright"><?php previous_posts_link('Nächste Einträge »') ?></div> </div> <?php else : ?> <h2 class="center">Nicht gefunden</h2> <p class="center">Sorry, aber du suchst gerade nach etwas, was hier nicht ist.</p> <?php include (TEMPLATEPATH . "/searchform.php"); ?> <?php endif; ?> </div> <?php get_sidebar(); ?> <?php get_footer(); ?> </body> </html> -
Ich will nicht einige Male die Postings ausgegeben haben sondern eben nur einmal (reicht ja auch, oder :) ?
Ausserdem ist die sidebar nicht mehr da
-
Aber was angezeigt wird ist absoluter Schwachsinn auf der Seite.
Es muss schon was Gravierendes falsch sein
Und wie mache ich ne class aus der ID, wie muss das dann aussehen ?
Ich habe mal alles rausgeschmissen und nur 1CAT drin !
Code ist jetzt so:
ZitatAlles anzeigen</head>
<body><div id="content" class="narrowcolumn">
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?><div class="kategorie-start">Boulevard</div>
<div class="entry">
<div id="cats">
<?php query_posts('cat=14&showposts=3'); ?>
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> <?php the_content_limit(400, "mehr...");?>
</div>
</div>
<?php endwhile; ?><div class="navigation">
<div class="alignleft"><?php next_posts_link('« Vorherige Einträge') ?></div>
<div class="alignright"><?php previous_posts_link('Nächste Einträge »') ?></div>
</div>
<?php else : ?><h2 class="center">Nicht gefunden</h2>
<p class="center">Sorry, aber du suchst gerade nach etwas, was hier nicht ist.</p>
<?php include (TEMPLATEPATH . "/searchform.php"); ?><?php endif; ?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
</body>
</html>Jetzt wiederholt er aber das CAT immer und immer wieder endlos
-
Hallom
ja, das habe ich verstanden. Danke.
Aber: Ich weiss nicht, wie ich dann weiter machen muss bzw. wie es exakt und korrekt eingefügt gehört (das cats mit seinen Klassen).
Wärest Du vielleicht so lieb und würdest mir das einmal zusammenkopieren (also code) so wie es sich gehört ?
Dann bekomme ich keine fehlermeldungen mehr und weiß es für alle Zeiten :) ?????Oder machen wirs so: Was ist daran noch falsch:
PHP
Alles anzeigen<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <meta name="generator" content="HTML Tidy for Linux (vers 1 September 2005), see www.w3.org"> <title></title> <style type="text/css"> a.c1 {color:#c00} </style> </head> <body> <div id="content" class="narrowcolumn"> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div class="post" id="post-<?php the_ID(); ?>"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <!-- von <?php the_author() ?> --></small> <div class="entry"> <a href="/schlager-boulevard"<div class="kategorie-start">Boulevard</div></a> <div class="entry"> <div id="cats"> <?php query_posts('cat=14&showposts=3'); ?> <?php while (have_posts()) : the_post(); ?> <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> <?php the_content_limit(400, "mehr...");?> <?php endwhile;?> </div> </div> <a href="/schlager-boulevard"<div class="kategorie-start">Boulevard</div></a> <div class="entry"> <div id="cats"> <?php query_posts('cat=14&showposts=3'); ?> <?php while (have_posts()) : the_post(); ?> <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> <?php the_content_limit(400, "mehr...");?> <?php endwhile;?> </div> </div> <a href="/schlager-boulevard"<div class="kategorie-start">Boulevard</div></a> <div class="entry"> <div id="cats"> <?php query_posts('cat=14&showposts=3'); ?> <?php while (have_posts()) : the_post(); ?> <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> <?php the_content_limit(400, "mehr...");?> <?php endwhile;?> </div> </div> </div> <p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Kategorie <?php the_category(', ') ?> <strong>|</strong> <?php comments_popup_link('0 Kommentare »', '1 Kommentar »', '% Kommentare »'); ?> </div> <?php endwhile; ?> <div class="navigation"> <div class="alignleft"><?php next_posts_link('« Vorherige Einträge') ?></div> <div class="alignright"><?php previous_posts_link('Nächste Einträge »') ?></div> </div> <a href="/schlager-boulevard"<div class="kategorie-start">Boulevard</div></a> <div class="entry"> <div id="cats"> <?php query_posts('cat=14&showposts=3'); ?> <?php while (have_posts()) : the_post(); ?> <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> <?php the_content_limit(400, "mehr...");?> <?php endwhile;?> </div> </div> <a href="/schlager-boulevard"<div class="kategorie-start">Boulevard</div></a> <div class="entry"> <div id="cats"> <?php query_posts('cat=14&showposts=3'); ?> <?php while (have_posts()) : the_post(); ?> <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> <?php the_content_limit(400, "mehr...");?> <?php endwhile;?> </div> </div> <a href="/schlager-boulevard"<div class="kategorie-start">Boulevard</div></a> <div class="entry"> <div id="cats"> <?php query_posts('cat=14&showposts=3'); ?> <?php while (have_posts()) : the_post(); ?> <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> <?php the_content_limit(400, "mehr...");?> <?php endwhile;?> </div> </div> <?php else : ?> <h2 class="center">Nicht gefunden</h2> <p class="center">Sorry, aber du suchst gerade nach etwas, was hier nicht ist.</p> <?php include (TEMPLATEPATH . "/searchform.php"); ?> <?php endif; ?> </div> <?php get_sidebar(); ?> <?php get_footer(); ?> </body> </html>