Afisare pagini specifice pe pagina principala in locul ultimelor postari
13 iun. 2012, 00:05:00
Vizualizări: 68
Voturi: 0
Sunt afisate 3 pagini recente pe site-ul meu WordPress. Iata codul:
<div id="main_posts">
<?php
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('showposts=3'.'&paged='.$paged . '&post_type=page' );
?>
<?php //query_posts('showposts=3'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="main_post">
<?php $image = get_post_meta($post->ID, 'Image', true); ?>
<a href="<?php the_permalink(); ?>">
<img class="post_image" width="251" height="292" src="<?php echo $image; ?>" alt="Imagine postare" title="Imagine postare" />
<div class="main_post_title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
</div>
Doresc sa afisez 3 pagini specifice pe pagina principala. Cum pot realiza acest lucru?

TM23
101
Toate răspunsurile la întrebare
1
0
Acest cod ar trebui să funcționeze prin introducerea ID-urilor corecte. Atributul paged este inutil aici, deoarece veți afișa întotdeauna aceleași articole.
<div id="main_posts">
<?php
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query(array(
'showposts' => 3,
//'paged' => $paged,
'post_type' => 'page',
'post__in' => array(1, 2, 3) // ID-urile articolelor dvs.
));
?>
<?php //query_posts('showposts=3'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="main_post">
<?php $image = get_post_meta($post->ID, 'Image', true); ?>
<a href="<?php the_permalink(); ?>">
<img class="post_image" width="251" height="292" src="<?php echo $image; ?>" alt="Imagine articol" title="Imagine articol" />
<div class="main_post_title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
</div>

Mathias
66
13 iun. 2012 01:14:32
Întrebări similare
1
răspunsuri
1
răspunsuri