WordPress dyanmic page code…

wordpress dyanmic page code

 
Post code
 
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
 
……………………………………………………………….
category id select
 
 
 
<?php if ( have_posts() ) : ?>
<?php query_posts(‘cat_ID=22’); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
……………………………………………………………………..
 next and prv chose post select catergory
<ul>
<?php
 
global $post;
 
$args = array( ‘posts_per_page’ => 5, ‘offset’=> 1, ‘category’ => 1 );
 
$myposts = get_posts( $args );
 
foreach( $myposts as $post ) : setup_postdata($post); ?>
                <li>
          <a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a>
        </li>
<?php endforeach; ?>
 
</ul>
…………………………………………………………………………………
ALl post calling code
 
<?php
$args = array( ‘posts_per_page’ => 3 );
$lastposts = get_posts( $args );
foreach($lastposts as $post) : setup_postdata($post); ?>
                <h2><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></h2>
                <?php the_content(); ?>
<?php endforeach; ?>
………………………………………………………………………….
Select catgory all post display page
 
<?php
$args = array(  ‘posts_per_page’ => 5,’category’ => 24);
$lastposts = get_posts( $args );
foreach($lastposts as $post) : setup_postdata($post); ?>
                <h2><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></h2>
                <?php the_content(); ?>
<?php endforeach; ?>
………………………………………………………………………………….
<?php $the_query = new WP_Query( ‘showposts=1’ ); ?>
 
    <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
    <li><a href=”<?php the_permalink() ?>”><?php the_title(); ?></a></li>
 
    <li><?php the_content(__(‘(more…)’)); ?></li>
    <?php endwhile;?>
…………………………………………………………………………….
Calling image or any link
 
<?php bloginfo( ‘template_url’ ); ?>/
<?php bloginfo(‘template_directory’); ?>/
 
……………………………………………………………………………..
 
menu calling code
 
1.  <?php wp_nav_menu( array( ‘menu’ => ‘my’)); ?>             Note: my is name of menu
 
2.   <?php wp_nav_menu( array( ‘theme_location’ => ‘primary’ ) ); ?>
 
3.        <a href=”<?php echo home_url(); ?>”>Home</a>
           <?php wp_list_pages(‘title_li=’); ?>
 
………………………………………………………………………………….
Sub menu calling code
 
 <?php
$parent = get_post($post->post_parent);
if($parent->post_parent) {
$children = wp_list_pages(“title_li=&child_of=”.$parent->post_parent.”&echo=0&depth=1″);
} elseif ($post->post_parent) {
$children = wp_list_pages(“title_li=&child_of=”.$post->post_parent.”&echo=0&depth=1″);
} else {
$children = wp_list_pages(“title_li=&child_of=”.$post->ID.”&echo=0&depth=1″);
}
if ($children) { ?>
<?php echo $children; ?>
 
    <?php } ?>
 
………………………………………………………………………………..
categories menu calling code
 
<li><a href=”<?php echo home_url(); ?>”>Home</a></li>
                <li><?php wp_list_categories(‘title_li=&’); ?></li>
…………………………………………………………………………..
 
Side bar COde
 
<?php get_sidebar(); ?>
 
……………………………………………………………………..
Search form code
 
<?php get_search_form(); ?>
 
………………………………………………………………………………..
comments calling code
 
<?php comments_template(); ?>
…………………………………………………………………………………
Dynamic page create wordpress code
 
<?php
 
/*
 
Template Name: THE fruit display
 
*/ 
?>
<?php get_header(); ?>
 
In this place puting HTML css code
 
<?php get_footer(); ?>
 
………………………………………………………………
 
Posting code index.php page
 
 
  <?php if ( have_posts() ) : ?>
 <?php twentyeleven_content_nav( ‘nav-above’ ); ?>
 <?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php the_title(); ?>
                  
<?php the_content(‘Read the rest of this entry &raquo;’); ?>
<?php endwhile; ?>
 
<?php twentyeleven_content_nav( ‘nav-below’ ); ?>
 
<?php else : ?>
 
<article id=”post-0″>
<header>
<h1><?php _e( ‘Nothing Found’, ‘twentyeleven’ ); ?></h1>
</header><!– .entry-header –>
 
<div>
<p><?php _e( ‘Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.’, ‘twentyeleven’ ); ?></p>
<?php get_search_form(); ?>
</div><!– .entry-content –>
</article><!– #post-0 –>
 
<?php endif; ?>
……………………………………………………………………………………………………………………..
page .php file calling post code
 
 
<?php while ( have_posts() ) : the_post(); ?>
 
<?php get_template_part( ‘content’, ‘page’ ); ?>
 
<?php comments_template( ”, true ); ?>
 
<?php endwhile; // end of the loop. ?>
 
 
………………………………………………………………………………………………………
dyanamic widgit code and calling code
 
create widgit code function.php file
 
  <?php       register_sidebar( array(
‘name’ => __( ‘Showcase Sidebar’, ‘twentyeleven’ ),
‘id’ => ‘sidebar-2’,
‘description’ => __( ‘The sidebar for the optional Showcase Template’, ‘twentyeleven’ ),
‘before_widget’ => ‘<aside id=”%1$s”>’,
‘after_widget’ => “</aside>”,
‘before_title’ => ‘<h3>’,
‘after_title’ => ‘</h3>’,
                ) );
                ?>
……………………………………………
calliing widgit code
 
  <?php if ( is_active_sidebar( ‘sidebar-6’ ) ) : ?>
                <div id=”four” role=”complementary”>
                                <?php dynamic_sidebar( ‘sidebar-6’ ); ?>
                </div><!– #third .widget-area –>
                <?php endif; ?>
………………………………………………………………………………………………………………..

 

Standard

Leave a comment