Thursday 11 July 2013

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; ?>
................................................................................
<?php
$args = array(  'posts_per_page' => 10,'category' => 4);
$lastposts = get_posts( $args );
foreach($lastposts as $post) : setup_postdata($post); ?>
                <h3 style="text-transform: uppercase;
    font-weight: 600;text-align:center;padding:10px"><?php the_title(); ?></h3>
                <p style="font-size:16px;padding:0px 30px"><?php the_content(); ?></p>
<?php endforeach; ?>

.................................................
<?php
require('wp-blog-header.php');
?>
<?php query_posts('showposts=10&cat=4'); ?>
<?php while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php the_content(__('Read more'));?>
<?php endwhile;?>

.........................................................
<?php
$args = array(  'posts_per_page' => 10,'category' => 4);
$lastposts = get_posts( $args );
foreach($lastposts as $post) : setup_postdata($post); ?>
             <?php the_title(); ?>
             

<?php the_excerpt(); ?>
<a href=”<?php the_permalink(); ?>”>Read more…</a>
<?php endforeach; ?>
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
 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" class="post no-results not-found">
<header class="entry-header">
<h1 class="entry-title"><?php _e( 'Nothing Found', 'twentyeleven' ); ?></h1>
</header><!-- .entry-header -->

<div class="entry-content">
<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" class="widget %2$s">',
'after_widget' => "</aside>",
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
                ) );
                ?>
...................................................
calliing widgit code

  <?php if ( is_active_sidebar( 'sidebar-6' ) ) : ?>
                <div id="four" class="widget-area" role="complementary">
                                <?php dynamic_sidebar( 'sidebar-6' ); ?>
                </div><!-- #third .widget-area -->
                <?php endif; ?>
................................................................................................................................


Call all page id wise

<a href="<?php echo get_page_link(40); ?>">Map</a>



No comments:

Post a Comment

Featured post

Life Infotech now a leading brand in the field of technology training

  Life Infotech now a leading brand in the field of technology training & its invites students around the nation to be a part of the Tra...