You are on page 1of 12

http://www.billerickson.

net/code/wp_query-arguments/

//** Formula with if conndition content dispaly with get field **//

<?php if (($content = get_field('content')) && !empty($content)): ?>

<?php echo $content; ?>


<?php endif; ?>

//** how to get image with if conndition **//

<?php if (($image = get_field('image')) && !empty($image)): ?>


<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?
>"/>
<?php endif; ?>

<?php if(!empty($staff_image)):?>
<img src="<?php echo $staff_image['sizes']['size282x205']; ?>" alt="<?
php echo $staff_image['alt']; ?>" />
<?php endif; ?>

//** direct image lene k liye **//

<img src="<?php echo get_template_directory_uri(); ?>/images/feedback.jpg">

//** background se -image lene k liye **//


<?php if (($slide_image = get_field('slide_image')) && !
empty($slide_image)) ?>
<div style="background-image: url(<?php echo $slide_image['sizes']
['size1600x800']; ?>);">
<?php endif; ?>

function me ye add krna padega :-


// thumb option start here
add_theme_support( 'post-thumbnails' );
add_image_size( 'size282x205', 282, 205 );

14:51 19-01-2017
//** HOW TO GET IMAGE WITH REPEATER & SLIDE SHOW**//

<?php if( have_rows('slider_image') ): ?>


<?php while ( have_rows('slider_image') ) : the_row(); ?>

<?php $image = get_sub_field('image');?>


<img src="<?php echo $image['url']; ?>" alt="<?php echo
$image['alt']; ?>"/>

<?php endwhile; ?>


<?php else : ?>
<?php endif; ?>

//** NEWS FETCH KRVANE K LIYE **//

<?php
$args = array(
'post_type'=> 'post',
'posts_per_page'=> 2,
);
$loop = new WP_Query(args);
?>

<?php if($loop->have_posts()):?>
<h2>VIKING IN THE NEWS</h2>
<?php while($loop->have_posts()): $loop->the_post();?>

<h3><?php the_title();?></h3>
<span><?php the_time('M d, Y');?></span>

<?php endwhile; ?>


<?php endif; ?>

//** sidebar lagne k liye **//

<?php if ( is_active_sidebar( 'page-sidebar' ) ) : ?>


<?php dynamic_sidebar('page-sidebar'); ?>
<?php endif; ?>

//** Page.php k banner image ko show krne ka code **//

<?php $slider_image = get_sub_field('slider_image');?>


<div style= "height: 213px; background-image: url(<?php echo
$slider_image['sizes']['size1900x213']; ?>);">

//** repeater k andar repeater chalane k liye **// project name-vikingpartnersllc


and template-case.php

<?php if( have_rows('corporate') ): ?>


<?php while( have_rows('corporate') ): the_row(); ?>

<?php if( ($corporate_title = get_sub_field('corporate_title'))&& !


empty($corporate_title)): ?>
<?php echo $corporate_title; ?>
<?php endif;?>

<?php if( have_rows('person_detail') ): ?>


<?php while( have_rows('person_detail') ): the_row(); ?>

<?php if( ($name = get_sub_field('name'))&& !empty($name)): ?>


<?php echo $name; ?>
<?php endif;?>

<?php if( ($designation = get_sub_field('designation'))&& !


empty($designation)): ?>
<?php echo $designation; ?>
<?php endif;?>

<?php if( ($email = get_sub_field('email'))&& !empty($email)): ?>


<?php echo $email; ?>
<?php endif;?>

<?php if( ($phone = get_sub_field('phone'))&& !empty($phone)): ?>


<?php echo $phone; ?>
<?php endif;?>

<?php endwhile; ?>


<?php endif; ?>

<?php endwhile; ?>


<?php endif; ?>

//** feature image lene k liye (post page k liye) **//

<?php $url = wp_get_attachment_url(get_post_thumbnail_id());?>


<img src="<?php echo $url; ?>" alt=""/><br>

//** post feature image **//

<?php $url = wp_get_attachment_url(get_post_thumbnail_id($projects['ID']));?>


<div class="recent" style="background-image: url(<?php echo $url;?>);">

//** post se title fetch krne k liye **//

<?php echo $projects['post_title']; ?>

//** post parmalink lagane k liye or button and hard code text ke through **//

<a href="<?php echo get_permalink($projects['ID']); ?>" class="btn btn-


primary"><?php _e('Project bekijken');?> </a>

//** post date karne k liye **//

<?php echo get_the_date ('d,m,Y', $projects['ID']); ?>

//** Post permalink lagane k liye **//

<a href="<?php echo get_permalink($projects['ID']); ?>"><?php _e('Project


bekijken');?> </a>

s
//** post code ka full code **//

<?php
$args = array(
'numberposts' => 1,
'offset' => 0,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'project',
'post_status' => 'publish,',
'suppress_filters' => true
);

$recent_posts = wp_get_recent_posts( $args, ARRAY_A );


$projects = $recent_posts[0];
?>

<?php if(!empty($projects)): ?>


<?php $url = wp_get_attachment_url(get_post_thumbnail_id($projects['ID']));?>
<div class="recent" style="background-image: url(<?php echo $url;?>);">
<div class="container">
<div class="recent__project">
<h2><?php _e('Recente');?><span><?php _e('Project');?
></span></h2>
<h3> <?php echo $projects['post_title']; ?
></h3>
<?php echo get_the_date ('d,m,Y', $projects['ID']); ?>

<a href="<?php echo get_permalink($projects['ID']); ?>"


class="btn btn-primary"><?php _e('Project bekijken');?> </a>
</div>
</div>
</div>
<?php endif; ?>

//** All post post krne k liye use hoga**//

<?php
$args = array(
'numberposts' => 2,
'post_type' => 'event',
'order' => 'DESC',
'post_status' => 'publish',

);

// query
$the_query = new WP_Query( $args );
?>

<?php if( $the_query->have_posts() ): ?>


<?php while( $the_query->have_posts() ) : $the_query->the_post(); ?>

<a href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a>


<?php the_content(); ?>

<?php endwhile; ?>


<?php endif; ?>

//** Latest/Recent Post lene k liye codee **//

<?php
$args = [
'post_type' => 'event',
'order' => 'desc',
'posts_per_page' => - 1
];
$latest = new WP_Query( $args );
?>
<?php if ( $latest->have_posts() ): ?>
<?php while ( $latest->have_posts() ): $latest->the_post(); ?>

<a href="<?php the_permalink();?>"


target="_blank"><?php the_title(); ?></a>

<?php the_content(); ?>


<?php endwhile;?>
<?php endif; ?>

//** Slick slide se lene k liye **//

$(document).ready(function(){
$('.task').slick({
slidesToShow: 2,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: 1000,
});
});

<div class="task">
<div><img src="img/1.jpg"> </div>
<div><img src="img/2.jpg"> </div>
</div>

//** slider show krne k liye or button link or label k liye bhi use hoga **//

<div class="slider">
<?php if( have_rows('slider') ): ?>
<?php while ( have_rows('slider') ) : the_row(); ?>

<?php $image = get_sub_field('image');?>


<div>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>"/>
</div>
<?php if( ($title = get_sub_field('title'))&& !
empty($title)): ?>
<h2> <?php echo $title; ?><br></h2>
<?php endif;?>

<?php if ((($button_label = get_sub_field('slide_label')) && !


empty($button_label)) && (($button_link = get_sub_field('slide_link')) && !
empty($button_link))): ?>
<a href="<?php echo get_permalink($button_link); ?>" class="button"><?php
echo $button_label; ?></a>
<?php endif; ?>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>

//** ager hum theme option koi bhi value fatch krte h to 'option' ka use karna
padega**//

<?php if (($phone = get_field('phone','option')) && !empty($phone)): ?>


<?php echo $phone; ?>
<?php endif; ?>
<?php if (($email = get_field('email','option')) && !
empty($email)): ?>
<?php echo $email; ?>
<?php endif; ?>
//** footer me copy right show karne k liye **//

<p> <?php echo date( 'Y' ); ?> <?php echo _( "All Rights Reserved." ); ?>
</p>

//** image lane k liye direct url **//

<img src="<?php echo get_template_directory_uri(); ?>/images/facebook.jpg">


<a href="<?php the_field('facebook','option'); ?>">Facebook</a> <br>

<a href="<?php the_field('facebook'); ?>"><img src="<?php echo


get_template_directory_uri(); ?>/images/facebook1.jpg"> </a>

**<a href="<?php the_permalink(); ?>"><?php _e('read more');?></a>

??//** post fetch karvane k liye **//

<?php
$args = [
'post_type' => 'project',
'order' => 'desc',
'posts_per_page' => - 1
];
$latest = new WP_Query( $args );
?>
<?php if ( $latest->have_posts() ): ?>
<div>
<aside>
<div>
<ul>
<?php while ( $latest-
>have_posts() ): $latest->the_post(); ?>
<li>
<?php the_title(); ?></a>
<?php the_excerpt(); ?>

<?php if(has_post_thumbnail())
{ the_post_thumbnail();
} ?>

<a href="<?php the_permalink(); ?>"><?php _e('read more');?


></a>
</li>
<?php endwhile;
wp_reset_query(); ?>
</ul>
</div>
</aside>
</div>
<?php endif; ?>
//** photo fetch karne or logo ka link lagne k liye widget k through **//

<?php if (($facebook = get_field('facebook', $widget_id)) && !


empty($facebook)): ?>
<a href="<?php echo $facebook;?>" target="_blank"> <img src="<?php echo
get_template_directory_uri(); ?>/images/facebook.jpg"> </a>
<?php endif; ?>

widget ka title show krne ke liye

<?php if (!empty($instance['title'])) : ?>


<?php echo $args['before_title'] . apply_filters('widget_title',
$instance['title']) . $args['after_title']; ?>
<?php endif; ?>

//*** post type asign krne k liye **//

<?php
$args = array(
'numberposts' => 2,
'offset' => 0,
'category' => 0,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'post',
'post_status' => 'publish',
'suppress_filters' => true
);

$recent_posts = wp_get_recent_posts( $args, ARRAY_A );


?>

<?php if(!empty ($recent_posts)):?>


<div class="article__recent">
<div class="centering">
<h2><?php _e('Blog');?></h2>
<?php foreach ($recent_posts as $recent):?>
<aside>
<span><?php echo get_the_date('M d',$recent['ID']);?></span>
<h3><a href="<?php echo get_permalink($recent['ID']);?>"><?php
echo $recent['post_title'];?></a></h3>
<p><?php echo
wp_trim_words(get_the_content($recent['ID']),40,'...');?></p>
</aside>
<?php endforeach;?>
<a href="<?php echo get_permalink(get_option( 'page_for_posts')); ?>"><?php
_e('Go To Blog');?></a>
</div>
</div>
<?php endif; ?>

//** email subcribe email button lagne k liye **//

[email* email placeholder "Your email"]


<button type="submit" class="wpcf7-submit">Submit</button>
//** contact or email href link lagne k liye **//

<?php if (($telephone = get_field('telephone')) && !empty($telephone)): ?>


<a href="tel:<?php echo $telephone; ?>"> <?php echo $telephone; ?><a/>
<?php endif; ?>

<?php if (($email = get_field('email')) && !empty($email)): ?>


<a href="mailto:<?php echo $email; ?>"> <?php echo $email; ?><a/>
<?php endif; ?>

//** Template part ka link lene k liye**//


<?php get_template_part('template-parts/content','top');?>

//** Customize widget lagne k liye function file me copy krege **//

include('widget/contact/widget.php');
include('widget/contact/output.php');

//*** hard code button banne k liyee **//

<?php if ((($assortment_link = get_field('assortment_link')) && !


empty($assortment_link))): ?>
<a href="<?php echo get_permalink($assortment_link); ?>" class="button"><?php
_e('Klik hier >');?></a>
<?php endif; ?>

//** hard code text banne k liye **//

<h2> <?php _e('Recente');?>


<span> <?php _e('Project');?>
</span>
</h2>

//** right page side bar me new banne k liye function me jana hoga fir **//

// side bar option start here


if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'name' => 'Page Sidebar',
'id' => 'page-sidebar',
'description' => 'This area for Default Sidebar',
'before_widget' => '<div id="%1$s" class="widget %2$s col-sm-3">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
));
// side bar option end here
// side bar option start here
register_sidebar(array(
'name' => 'Right Sidebar',
'id' => 'right-sidebar',
'description' => 'This area for Default Sidebar',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
));
}
// side bar option end here

//** short code contact form lane k liye**//

<?php if (($short_code = get_field('short_code')) && !empty($short_code))


{
echo do_shortcode(get_field('short_code'));
} ?>

//** function file me custome post add karne k liye **//

//Register theme custom post types


function register_custom_post_types() {

register_post_type( 'Event',
[
'labels' => [
'name' => _( 'Event' ),
'singular_name' => _( 'Event' ),
'menu_name' => _( 'Events' ),
],
'public' => true,
'publicly_queryable' => true,
'menu_icon' => 'dashicons-admin-post',
'has_archive' => false,
'rewrite' => [ 'slug' => 'case' ],
'supports' => [ 'title', 'editor','thumbnail' ],
]
);
}

add_action( 'init', 'register_custom_post_types' );

//** mujhe front page pr ye form nhi chaiye tha mene is code ka use kiya <?php
if(! is_front_page()):?>
<?php endif; ?> **//

<?php if ( !is_front_page() ) : ?>

<?php if (($short_code1 = get_field('short_code1','option')) && !


empty($short_code1))
{
echo do_shortcode(get_field('short_code1','option'));
} ?>

<?php endif; ?>


//** logo par hyperlink lagane k liye jisse click krne pr home page pr aa jaye **//

<div class="header__logo">
<?php if (($logo = get_field('logo', 'option')) && !
empty($logo)): ?>
<a href="<?php echo esc_url(home_url()); ?>">
<img src="<?php echo $logo['url']; ?>" alt="<?php
bloginfo('name'); ?>">
</a>
<?php else: ?>
<a href="<?php echo esc_url(home_url()); ?>">
<img src="<?php echo get_template_directory_uri() ?
>/images/logo.png" alt="<?php bloginfo('name'); ?>">
</a>
<?php endif; ?>

</div>

//** paginate page < 1 2 3 4 > karne ka code **//


<?php
$args = array(
'posts_per_page' => 4,
'paged'=>$paged,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'impression',
'post_status' => 'publish',
);
$the_query = new WP_Query( $args );
?>
<?php if( $the_query->have_posts() ): ?>

<div class="pagination">

<?php
$big = 999999999; // need an unlikely integer

$paginate = paginate_links( [
'prev_text' => __('<i class="fa fa-chevron-
left" aria-hidden="true"></i>'),
'next_text' => __('<i class="fa fa-chevron-
right" aria-hidden="true"></i>'),
'total' => $the_query->max_num_pages
] );
?>
<?php echo $paginate; ?>
<?php endif; ?>
</div>

//** read more lagne k liye post type function me **//

1. <?php echo wp_trim_words( get_the_content(), 80, '.........'); ?> <a href="<?


php the_permalink(); ?>">read more</a>
2. <?php the_excerpt(); ?>

//** breadcrumb lagane k liye pehle seo me jana hoga fir advance field me jakar
enable krna hoga fir jaha breadcrumb chaiye vaha ye code lagana hoga **//

<p>
<?php if ( function_exists('yoast_breadcrumb') ) {
yoast_breadcrumb(); } ?></p>

<?php
if (function_exists('yoast_breadcrumb')) {
yoast_breadcrumb('<p id="breadcrumbs">', '</p>');
}
?>

//** Home page pr logo lagane k liye or is pr click krne pr home page jane k chaiye
ka code **//

<?php if (($header_logo = get_field('header_logo','option')) && !


empty($header_logo)): ?>
<a href="<?php echo esc_url(home_url()); ?>"><img src="<?php echo
$header_logo ['url']; ?>" alt="<?php bloginfo('name') ?>"/></a>

<?php else: ?>


<a href="<?php echo esc_url(home_url()); ?>"> <img src="<?php
echo get_template_directory_uri() ?>/images/logo.png" alt="<?php
bloginfo('name'); ?>">
</a>
<?php endif; ?>

//** single.php pr news blog ka title fetch krne k liye **//

<?php
$title = get_option( 'page_for_posts' );
?>
<h2><?php echo get_the_title ($title); ?></h2>

//** upload file krne k liye any file coustome field me choose krna file **//

<?php if (($upload_file = get_field('upload_file')) && !empty($upload_file)):


?>
<a href="<?php echo $upload_file; ?>" target="_blank">
Download [.pdf] </a>
<?php endif; ?>
//** ek button jo kisi pr nhi aa rha h bs contact page pr aa rha h uske liye hum
**//

<?php
if (is_page_template('templates/template-contact.php')): ?>

<?php if ((($button_label = get_field('button_label', $widget_id)) && !


empty($button_label)) && (($button_link = get_field('button_link', $widget_id))
&& !empty($button_link))): ?>
<p> <a href="<?php echo $button_link; ?>" class="button"
target="_blank"><?php echo $button_label; ?></a></p>
<?php endif; ?>

<?php endif; ?>

//** Menu Show karvane k liye code **//

<?php
wp_nav_menu( array(
'theme_location' => 'header_main_menu',
'depth' => 2,
'container' => '',
'menu_class' => ''
));
?>

You might also like