18. februar 2009 - 17:08
Der er
1 kommentar
wordpress custom side
Hej,
Jeg vil gerne have lavet en custom side i min wordpress blog, som viser posts der har et bestemt custom field tilknyttet.
Her er min side ind til videre:
<?php
/*
Template Name: test
*/
?>
<?php get_header(); ?>
<!-- Content Wrap -->
<div id="galleryWrap">
<!-- Gallery -->
<div id="gallery">
</div><!-- [END] gallery content -->
<?php get_sidebar();?>
</div><!-- [END] galleryWrap -->
<?php get_footer(); ?>
Hvordan får jeg så alle de posts frem som har et custom field der hedder "upcoming", og helst vise de nyeste først.
på forhånd tak.
11. marts 2009 - 13:48
#1
Hvis jeg var dig, ville jeg istedet bruge at kalde en bestemt kategori istedet... Så kan du bare lave en "upcoming" kategori, og så hver gang du skriver et indlæg der skal vises på den side, vælger du bare kategorien "Upcoming"... du kan jo også sagtens vælge flere kategorier til dit indlæg...
brug evt denne kode til at hente indlæg fra en kategori: (bare udskift cat=15 med det tal den kategori du opretter får)
<?php query_posts('showposts=1&cat=15'); ?> <!-- Edit the cat= part to the number of the desired category (check the category IDs in your WordPress system), and this will show the 1st of the chosen category -->
<?php while (have_posts()) : the_post(); ?>
<h2><?php the_category(', '); ?><i> - <?php the_time('M j, Y G:i'); ?> - <a href="<?php the_permalink() ?>#commenting" title="Jump to the comments"><?php comments_number('0 Comments','1 Comment','% Comments'); ?></a></i></h2>
<h1><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1>
<?php the_content('Continue...'); ?>
<?php endwhile; ?> <!-- END -->
<?php query_posts('showposts=5&offset=1&cat=15'); ?> <!-- Show the 5 most recent articles in the already chosen category, first one not included -->
<h2>More In <?php single_cat_title(); ?></h2>
<ul>
<?php while (have_posts()) : the_post(); ?>
<li><span class="title"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></span>
<br />
<span class="meta"><?php the_time('l, F j, Y G:i'); ?> - <a href="<?php the_permalink() ?>#commenting" title="Jump to the comments"><?php comments_number('0 Comments','1 Comment','% Comments'); ?></a></span></li>
<?php endwhile; ?>