Zurück   WordPress Deutschland Forum > Support > Design > Theme-Entwicklung

Antwort
 
Themen-Optionen Ansicht
Alt 10.02.2008, 13:02   #1 (permalink)
PostRank: 1
 
Registriert seit: 04.02.2008
Beiträge: 22
Zweitneuester Post etc.

Kleine Frage:
Wie kann ich voneinander getrennt den neuesten Post einbinden, den zweitneuesten, drittneuesten, alle dahinter?
Ich kenne nur <? php the_content(); ?>
Gibt es da vlt ein Parameter wie the_content(12); um den 12.-neuesten Post und nur ihn einzubinden? Ich hoffe ihr versteht was ich meine.
taron ist offline   Mit Zitat antworten
Alt 10.02.2008, 13:14   #2 (permalink)
WPD-Moderator
 
Benutzerbild von marX
 
Registriert seit: 05.10.2006
Beiträge: 5.946
Template Tags/query posts « WordPress Codex
offset- und showposts-Parameter.

Aber wenn du uns verrätst, was genau du vor hast, dann kann man dir vielleicht auch ne bessere Lösung anbieten.
marX ist offline   Mit Zitat antworten
Alt 10.02.2008, 14:14   #3 (permalink)
PostRank: 1
 
Registriert seit: 04.02.2008
Beiträge: 22
Ich hatte vor, die Hauptseite so Zeitungs-mäßig mit verschiedenen Spalten etc. anzuordnen:

Der neueste Post kommt über die ganze Seitenbreite (Sidebars ausgenommen), der zweitneueste kommt darunter in die linke Bildschirmhälfte, Nummer 3 und 4 teilen sich übereinander liegend die rechte Hälfte, ab dann kommen darunter immer 4 Spalten (in jeder ein Post).

_____________
|...................|
|.......1..........|
|...................|
--------------------
|.........|....3...|
|....2....|---------|
|.........|....4..|
--------------------
|....|....|.....|...|
|..5.|.6.|.7 .|.8.|
|....|....|.....|....|
--------------------
.
.
.

(die Punkte dienen nur als Platzhalter, mit Leerzeichen funktioniert das hier anscheinend nicht.)
taron ist offline   Mit Zitat antworten
Alt 10.02.2008, 14:22   #4 (permalink)
WPD-Moderator
 
Benutzerbild von marX
 
Registriert seit: 05.10.2006
Beiträge: 5.946
Okay, würde ich anders lösen. Und zwar lässt du einen Zähler mitlaufen, damit zu weißt, den wievielten Post du gerade durchläufst. Dementsprechend gibst du dem umliegenden <div> eine Klasse mit. So in etwa:

PHP-Code:
<?php $postcount 1?>
<?php 
while ( have_posts() ) : the_post(); ?>
  <div class="post" id="post<?php $postcount?>">
     <!--weitere Template-Tags...-->
  </div><!--Post Close -->
<?php $postcount++; endwhile; ?>
Anhand der $postcount-Variable kannst du dann die einzelnen Container individuell stylen. Theoretisch könntest du auch so jeweils individuellen HTML-Code für jeden einzelnen Post erzeugen. (Aber damit bringst du für meinen Geschmack zuviel Programmlogik ins Template. )
marX ist offline   Mit Zitat antworten
Alt 11.02.2008, 18:14   #5 (permalink)
PostRank: 1
 
Registriert seit: 04.02.2008
Beiträge: 22
Okay, danke. Wo muss ich dann jetzt mein <tr> einsetzen?
So? (Für den ersten Post)
PHP-Code:
<table>
<?php $postcount 1?> 
<?php while ( have_posts() ) : the_post(); ?> 
<div class="post" id="post<?php $postcount?>"> 
<tr width="100%" border="1"><?php the_content(); ?></tr>
</div>
<?php $postcount++; endwhile; ?>
</table>
Ich kann leider kein PHP, daher die Nachfrage.

Geändert von Arno Simon (11.02.2008 um 18:23 Uhr).
taron ist offline   Mit Zitat antworten
Alt 11.02.2008, 18:22   #6 (permalink)
PostRank: 10
 
Benutzerbild von Arno Simon
 
Registriert seit: 30.11.2005
Ort: Oberhausen (Rhld.)
Beiträge: 1.646
ähm... nix für ungut, aber normalerweise sind wp-themes eigentlich table-freie zonen...... die anordnung und das zusammenspiel der divs am besten über die entsprechenden css-attribute gestalten.... wie es auch von marX bereits angeregt wurde...

und... coding demnächst bitte in die entsprechenden tags verpacken.. .siehe auch: Forums-Hinweis: Auszeichnung von Quelltext in den Posts

vG

Arno
__________________
Feedback ist Wichtig!|FAQ|Rückfragen im Forum!|Wenn ich mal was vergesse.... einfach mal sagen...
Arno Simon ist offline   Mit Zitat antworten
Alt 11.02.2008, 19:03   #7 (permalink)
WPD-Moderator
 
Benutzerbild von marX
 
Registriert seit: 05.10.2006
Beiträge: 5.946
Mit Tabellen wirst du ohne größeren Aufwand deine gewünschte Struktur nicht hinbekommen. Spätestens bei Post 3/4 bekommst du massiv Probleme. Da gehts nur noch mit verschachtelten Tabellen, und das wird echter Krampf. Das ist auch der Grund, warum man Tabellen nicht zum Layouten einsetzen soll, wie Arno bereits sagte.
Da wirst du mit meiner CSS-Variante deutlich besser hinkommen. CSS-Tutorials gibts zuhauf im Netz, einfach mal suchen.

Hier mal ein Minimalbeispiel:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Test</title>
<style type="text/css">
.post {
margin:0;
padding:0;
border:1px solid red;
overflow:hidden;
}
.post-1 {
width:30em;
height:5em;
}
.post-2 {
width:15em;
height:5em;
float:left;
}
.post-3 {
width:15em;
height:2.5em;
}
.post-4 {
width:15em;
height:2.5em;
}
.post-5 {
width:7.5em;
height:5em;
clear:left;
float:left;
}
.post-6, .post-7, .post-8 {
width:7.5em;
height:5em;
float:left;
}
</style>
</head>
<body>
<div class="post post-1">
1 Lorem ipsum dolor sit amet, consectetuer sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</div>
<div class="post post-2">
2 Lorem ipsum dolor sit amet, consectetuer sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</div>
<div class="post post-3">
3 Lorem ipsum dolor sit amet, consectetuer sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</div>
<div class="post post-4">
4 Lorem ipsum dolor sit amet, consectetuer sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</div>
<div class="post post-5">
5 Lorem ipsum dolor sit amet, consectetuer sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</div>
<div class="post post-6">
6 Lorem ipsum dolor sit amet, consectetuer sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</div>
<div class="post post-7">
7 Lorem ipsum dolor sit amet, consectetuer sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</div>
<div class="post post-8">
8 Lorem ipsum dolor sit amet, consectetuer sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</div>
</body>
Der generierte HTML-Code enspricht meinem Beispiel von oben (Nachtrag: die IDs/Klassne sind geringfügig anders... ). Die Styles kannst du übernehmen, musst sie aber sicher noch ein wenig an dein Design anpassen.
marX ist offline   Mit Zitat antworten
Alt 12.02.2008, 15:45   #8 (permalink)
PostRank: 1
 
Registriert seit: 04.02.2008
Beiträge: 22
Ich hab die immer div#post1, div#post2 usw genannt, ist das richtig?
Und für alle ab 4 habe ich dann einfach nur .post genommen. Das müsste dann doch gehen, wenn class=post ist und id=post1 usw., oder?

Noch eine Sache (ist mein erster Themeversuch): Die Themes, die ich aus dem Internet runtergeladen hab, haben alle mehrere Dateien wie index.php, header.php, sidebar.php... Ist das denn überhaupt nötig? Ich habe jetzt eine index.php (die den Code für die ganze Seite enthält) und eine css.css, die die Stylesheets enthält (und noch die comments.php vom Standard-theme).
taron ist offline   Mit Zitat antworten
Alt 12.02.2008, 16:00   #9 (permalink)
WPD-Moderator
 
Benutzerbild von marX
 
Registriert seit: 05.10.2006
Beiträge: 5.946
Zitat:
Zitat von taron Beitrag anzeigen
Ich hab die immer div#post1, div#post2 usw genannt, ist das richtig?
Japp. Das div könntest du sogar noch weglassen, also nur #post1 usw.

Zitat:
Und für alle ab 4 habe ich dann einfach nur .post genommen. Das müsste dann doch gehen, wenn class=post ist und id=post1 usw., oder?
Wenn die alle den gleichen Style bekommen sollen - ja. Die Angaben zu .post wirken sich auf alle Postings aus, über die ID kannst du spezielle Postings exakt ansprechen.

Zitat:
Noch eine Sache (ist mein erster Themeversuch): Die Themes, die ich aus dem Internet runtergeladen hab, haben alle mehrere Dateien wie index.php, header.php, sidebar.php... Ist das denn überhaupt nötig? Ich habe jetzt eine index.php (die den Code für die ganze Seite enthält) und eine css.css, die die Stylesheets enthält (und noch die comments.php vom Standard-theme).
Ist nicht nötig, theoretisch kannst du mit den 3-4 Dateien auskommen. Die weiteren Dateien benötigst du, um einfach andere Templates für Kategorielisting, Archiv, Einzelansicht, statische Seiten usw.usf. einzurichten. Das könntest du zwar auch über "Conditional Comments" machen, aber mit unterschiedlichen Template-Dateien ists sauberer und übersichtlicher. Siehe auch Doku:
Template Hierarchy « WordPress Codex
(da ist das auch schön mit einem Bild illustriert)

Nachtrag: die css.css solltest du style.css nennen. Dann kannst du an deren Anfang einen Kommentar hinterlassen mit Informationen über das Theme und den Autor. Diese werden dann auch im Backend im Theme-Switcher angezeigt. Kannst du bei anderen Templates sehen. Außerdem gibt es WP-Template-Tags, die direkt auf die style.css zugreifen - natürlich nur wenn die auch so heißt.

Geändert von marX (12.02.2008 um 16:03 Uhr).
marX ist offline   Mit Zitat antworten
Alt 13.02.2008, 18:48   #10 (permalink)
PostRank: 1
 
Registriert seit: 04.02.2008
Beiträge: 22
Ausschnitt aus der index.php:
PHP-Code:
<?php if (have_posts()) : ?>
<?php $postcount 
1?> 
<?php while ( have_posts() ) : the_post(); ?> 
  <div class="post" id="post<?php $postcount?>">  
  </div>
<?php $postcount++; endwhile; ?>
<div class="infos">Verfasst von <?php the_author() ?> &bull; 
Kategorien: <?php the_categorie(', '?> &bull; 
<?php comments_popup_link('Keine Kommentare''1 Kommentar''% Kommentare'); ?> &bull; 
<?php edit_post_link('Editieren','','·'); ?></div>

<?php next_posts_link('« vorherige Seite'?> - <?php previous_posts_link('n&auml;chste Seite »'?>
<?php 
else : ?>
<div class="post">
<h1>Es ist ein Fehler aufgetreten.</h1>
Die gew&uuml;nschte Seite ist nicht verf&uuml;gbar.
</div>
<?php endif; ?>
Ausschnitt aus styles.css:
Code:
/*Inhalt > Posts*/

div#post1 {
 margin: 0 12em 1em 16em;
 padding: 0 1 em;
 border: 1px grey;
 width: 80%;
}

div#post2 {
 margin: 0 12em 1em 16em;
 padding: 0 1 em;
 border: 1px grey;
 width: 40%;
}

div#post3 {
 margin: 0 12em 1em 16em;
 padding: 0 1 em;
 border: 1px grey;
 width: 40%;
}

div#post4 {
 margin: 0 12em 1em 16em;
 padding: 0 1 em;
 border: 1px grey;
 width: 40%;
}

div#post5 {
 margin: 0 12em 1em 16em;
 padding: 0 1 em;
 border: 1px grey;
 width: 40%;
}

.post {
 margin: 0 12em 1em 16em;
 padding: 0 1 em;
 border: 1px grey;
 width: 25%;
}

.post p {
 font-size: 10pt;
 font-family: sans-serif;
 color: black;
}

.post h1 {
 font-size: 16pt;
 font-family: sans-serif;
 color: black;
}

.post a:link {
 color: grey;
}

.post a:visited {
 color: grey;
}

.post a:hover {
 color: orange;
}

.post a:active {
 color: orange;
}

/*Inhalt > Postinfos*/

.infos {
 font-size: 8pt;
 font-family: sans-serif;
 color: black;
}

.infos a:link {
 color: grey;
}

.infos a:visited {
 color: grey;
}

.infos a:hover {
 color: orange;
}

.infos a:active {
 color: orange;
}
Ist das so richtig für ein Spaltenlayout? Ich bin mir vor allem nicht sicher bei den Infos (Kategorie, Autor, ...), die unten den Posts stehen sollten.

Geändert von taron (13.02.2008 um 21:43 Uhr).
taron ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist aus.
HTML-Code ist aus.
Trackbacks are aus
Pingbacks are aus
Refbacks are aus


Alle Zeitangaben in WEZ +2. Es ist jetzt 02:11 Uhr.


Powered by vBulletin® Version 3.7.3 (Deutsch)
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 | Impressum | Ein Inpsyde.com Projekt