Posts

How to Show Posts in Even Odd Format 1 Wordpress

<?php global $post; $args = array( 'numberposts' => 2, 'category_name' => 'site-plan' ); $posts = get_posts( $args ); $i=1; foreach( $posts as $post ): setup_postdata($post); $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID, 'thumbnail') ); if($i%2){ //$i%2 ? 'odd':'even') ?>   <div class="container white-block">     <div class="row margin-top-25">       <div class="col-md-6 col-sm-6">         <img src="<?php echo $url; ?>"alt="image" class="img-responsive img-align">       </div>       <div class="col-md-6 col-sm-6">         <h3 class="yellow-center-sub-heading erase-margin"><?php the_title();?></h3>         <p class="artical-text"><?php the_content();?></p>  ...

When User is Logged in

<div class="col-md-7 col-sm-6">       <?php if ( is_user_logged_in() ) { ?>         <div class="dropdown" id="drop-down-right">           <button class="btn dropdown-toggle drop-down-btn" type="button" data-toggle="dropdown">MY ACCOUNT<span class="caret"></span></button>      <?php $defaults = array( 'theme_location'  => '', 'menu'        => 'Top Right Menu', 'container'   => '', 'container_class' => '', 'container_id' => '', 'menu_class'  => 'dropdown-menu dollar-drop-down', 'menu_id'     => '', 'echo'        => true, 'fallback_cb' => 'wp_page_menu', 'before'      => '', 'after'       => '', 'link_before' => ...

To Show Only On Home Page Not Show on Other Page

  <?php if ( is_front_page() ) {  // This is the blog posts index  get_sidebar( 'blog' ); } else {  // This is not the blog posts index  get_sidebar(); } ?> <?php echo $postid = get_the_ID(); ?> <?php if($postid == '418') { ?> style="background-color:white;" <?php } ?> 

When First Item is active then Use that code

<?php global $post; $args = array( 'numberposts' => -1, 'category' => 3 ); $posts = get_posts( $args ); $i=0; foreach( $posts as $post ): setup_postdata($post); $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID, 'thumbnail') ); ?>    <div class="item <?php if($i==0) { ?> active <?php } else { } ?>"  style="background-image: url('<?php echo $url ?>')" >                     <div class="carousel-caption">                         <div class="animated bounceInRight">                             <h2><?php the_title(); ?></h2>  ...

Get Post Data From Simple Post custom shortcode

<div class="container" id="artical-block">     <h2 id="all-artical-head">All Articles</h2>     <?php     global $post;     $args = array( 'numberposts' => -1, 'category' => 31 );     $posts = get_posts( $args );     foreach( $posts as $post ): setup_postdata($post);     $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID, 'thumbnail') ); ?>        <div class=" col-md-12 artical-block">       <div class="row">         <div class="col-sm-3 col-md-3"><img src="<?php echo $url ?>" width="" height="" alt="image" class="img-responsive"></div>         <div class="col-sm-9 col-md-9">           <h4><?php the_title(); ?></h4>           <p class="date-timing">By <?php echo get_the_author()...