Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // For Post query that will support custom meta box & framework (this is custom post query). there are two code below you should use one
- <?php
- <?php if(!is_paged()) { ?>
- <?php
- $args = array( 'post_type' => 'sidebar_gallary2', 'posts_per_page' => -1 ); // thiscome from custom-posts.php
- $loop = new WP_Query( $args );
- ?>
- <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
- <?php
- $price_name = get_post_meta( $post->ID, 'price_name', true ); // this id from cmb(example-functions.php)
- ?>
- <!---------------------------------------------------------->
- <?php the_post_thumbnail('sidebar_gallary2_img_size', array('class' => '')); ?> <!--here is our data--->
- <!----------------------------------------------------------->
- <?php endwhile; ?>
- <?php wp_reset_query(); ?>
- <?php } ?>
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- OR // we can use by this way also
- <div class="fix global_post">
- <?php
- global $post;
- $args = array( 'posts_per_page' =>1, 'post_type'=> 'product_gallary' ); // thiscome from custom-posts.php
- $myposts = get_posts( $args );
- foreach( $myposts as $post ) : setup_postdata($post); ?>
- <?php
- $price_name = get_post_meta( $post->ID, 'price_name', true ); // this id from cmb(example-functions.php)
- $symble_name = get_post_meta( $post->ID, 'symble_name', true ); // this id from cmb(example-functions.php)
- $symble = get_post_meta( $post->ID, 'symble', true ); // this id from cmb(example-functions.php)
- $value = get_post_meta( $post->ID, 'value', true ); // this id from cmb(example-functions.php)
- $product_code = get_post_meta( $post->ID, 'product_code', true ); // this id from cmb(example-functions.php)
- ?>
- <div class="single_post_price_code">
- <?php if($price_name && $symble_name && $symble && $value && $product_code):?> <!---if more id exist for custom meta box---->
- <p><?php echo $price_name;?>: <color><?php echo $symble_name;?> <?php echo $symble;?><?php echo $value;?></color></p>
- <code>COD: <?php echo $product_code;?></code>
- <?php else:?>
- <!--here is default <data--->
- <p>Price: <color>US $ 45</color></p>
- <code>COD:0111A</code>
- <?php endif;?>
- </div>
- <?php endforeach;?>
- </div>
- //////////////////////////////////////// $args////////////////////////////////////////////////////////////////////////////////////////
- $args = array(
- 'post_type' => 'news_update', // thiscome from custom-posts.php
- 'posts_per_page' => 2,
- 'offset' => 0,
- 'category' => '',
- 'category_name' => '',
- 'orderby' => 'post_date',
- 'order' => 'DESC', // ASC OR DESC here ASC will show from previous post and DESC will show from recent post
- 'include' => '',
- 'exclude' => '',
- 'meta_key' => '',
- 'meta_value' => '',
- 'post_mime_type' => '',
- 'post_parent' => '',
- 'post_status' => 'publish',
- 'suppress_filters' => true
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement