Salutare,
Azi as dorii sa va ofer un mic tool care-l folosesc pe theme mele custom made WP.
Daca doriti sa editati o themea deja existenta sau doriti sa faceti voi una si doriti sa afisati sa zicem.... 4 coloane cu cele mai recente articole postate aveti nevoie de urmatorul cod :
E cam lung carnatul, dar asta e. Eu nu am reusit insa sa fac asta pe prima pagina a themei de wp. Ma refer ca.. pe o pagina gen "page.php" sau un template de pagina wp reusiesc sa integrez codul insa trebuie sa setez wp ca prima pagina sa fie una statica. si asta nu prea-mi convine.Cod PHP:<?php
// code to display a number of posts in multi columns top-to-bottom left-to-right
?>
<?php global $query_string; ?>
<?php
$set_number_of_columns = 4; // enter numbers of columns here;
$set_number_of_rows = 1; // enter numbers of rows here
$set_showpost = $set_number_of_columns * $set_number_of_rows ;
//setup query with parameter for paged
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts($query_string.'&showposts='.$set_showpost.'&paged='.$paged);
// get number of posts for this,
$num_of_posts = $wp_query->post_count;
// make adjustment for paged to get three equaly long columns even on last paged page
// divide by $set_number_of_columns to get number per column,
// round up to next integer to make $ppc posts per column variable, or $set_number_of_rows whatever is smaller
$ppc = min(ceil($num_of_posts/$set_number_of_columns),$set_number_of_rows);
// calculates number of rows, i.e. showposts for the following query_posts and get_posts
?>
<?php for ( $col = 1; $col <= $set_number_of_columns; $col += 1) { ?>
<div class="col<?php echo $col;?>">
<?php
$row = 1;
$noffset = ($col -1) * $ppc + ($paged - 1) * $set_showpost ; //calculate offset parameter if paged
$posts = get_posts($query_string.'&numberposts='.$ppc.'&offset='.$noffset);
foreach ($posts as $post) : start_wp(); ?>
<div id="post-<?php the_ID(); ?>" class="post row-<?php echo ($row%2); ?>">
<!-- start of anything to do with post -->
<a href="<?php the_permalink() ?>"><?php the_post_thumbnail(); ?></a>
<h3>
<a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
<div class="storycontent">
<?php the_excerpt(__('(more...)')); ?>
</div>
<!-- end of anything to do with post -->
</div> <!-- end #post -->
<?php
$row++;
endforeach; ?>
</div>
<?php } ?>
Haideti ca poate eu pun ceva util pentru cei care nu stiau asta si in acelasi timp ma invatati si pe minecum pot afisa postarile din blog pe prima pagina a unui wp dinamic fara pagina statica.
Toate bune!




cum pot afisa postarile din blog pe prima pagina a unui wp dinamic fara pagina statica.
Răspunde cu citat
