Thursday, May 13, 2010
Add page
<?php wp_list_pages('exclude=3,8,12,18,19,20,21,22,23&title_li=' ); ?>
Wednesday, May 12, 2010
show particular page in home page
<?php // retrieve one post with an ID of 5 query_posts('p=5');
global $more; // set $more to 0 in order to only get the first part of the post $more = 0;
// the Loop while (have_posts()) : the_post();
// the content of the post the_content('Read the full post »');
endwhile; ?>
Monday, May 3, 2010
How to show post from a particular category widget
<?php $my_query = new WP_Query('category_name=mycategory&showposts=1'); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
<?php the_title(); ?></a><br /><?php the_content(); ?><?php endwhile; ?>
===================================
<?php $args=array( 'cat' => 1, 'posts_per_page'=>5, 'caller_get_posts'=>1 );
$my_query = new WP_Query($args); if( $my_query->have_posts() ) {
echo '5 recent Posts from category 1'; while ($my_query->have_posts()) : $my_query->the_post(); ?>
<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<?php the_title(); ?></a></p>
<?php endwhile; } //if ($my_query) wp_reset_query();
// Restore global post data stomped by the_post(). ?>
Create a Widget Function Wordpress
Create a Widget Function
Paste this code to the theme
<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('photos') ) : else : ?>
-------------------------------
<?php endif; ?>
Add the to the functions.php
<?php
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'photos',
'before_widget' => '<div id="%1$s" class="widget">',
'after_widget' => '</div>',
'before_title' => '<h2 class="sidebartitle">',
'after_title' => '</h2>',
));
?>
Get 5 new posts for my homepage Wordpress
<div class="recent-five-posts">
<?php query_posts("orderby=desc&showposts=5"); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="individual-posts">
<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">Read More</a></h3>
<?php the_excerpt(); ?>
</div>
<?php endwhile; ?>
</div>