Thursday, February 28, 2019

How to install WordPress Multisite

https://visualcomposer.com/help/wordpress-tutorials/install-wordpress-multisite/

Tuesday, February 26, 2019

How to retrive the post using its custom category named "destination"

<?php $args = array('post_type' => 'trek','tour','expedition','activity','peak',
   'tax_query' => array(

array(
'taxonomy' => 'destination',
 'field'    => 'term_id',
 'terms'    => 11,
),

),
   'posts_per_page' => -1, 'orderby'=>'title','order'=>'ASC'); ?>
      <?php
$query = new WP_Query($args);
if($query->have_posts()):

while ($query->have_posts()):
$query->the_post();
?>

How to retrive the destination name of specific post in wordpress!!!

<?php
                    $terms = get_the_terms( $post->ID , 'destination');
                    foreach ( $terms as $term ) {?> 
                 
                    <div class="c-card__location"><i class="fa fa-map-marker"></i> <?php  echo $term->name;?></div>
                  <?php } ?>

Sunday, February 24, 2019

How to retrive the post from english category of custom post type english

https://codex.wordpress.org/Class_Reference/WP_Query

<?php
                   $args = array(
                        'showposts' => 4,
                        'offset'=>1,
                     
                  'tax_query' => array(
            array(
            'taxonomy' => 'english_category',
            'field' => 'slug',
            'terms' => 'travel',
           
                    )
                    )
                    );
                    $the_query = new WP_Query( $args );
                     if($the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post();
                     ?>

Tuesday, February 19, 2019

9-best-translation-plugins-for-wordpress-websites

https://www.wpbeginner.com/showcase/9-best-translation-plugins-for-wordpress-websites/?utm_source=pushnotification&utm_medium=onesignal&utm_campaign=blogpush

Tuesday, February 12, 2019

Popular post

<?php
$popularpost = new WP_Query( array( 'posts_per_page' => 4, 'meta_key' => 'wpb_post_views_count', 'orderby' => 'meta_value_num', 'order' => 'DESC'  ) );
while ( $popularpost->have_posts() ) : $popularpost->the_post();

  ?>



Function.php
function wpb_set_post_views($postID) {
    $count_key = 'wpb_post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        $count = 0;
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
    }else{
        $count++;
        update_post_meta($postID, $count_key, $count);
    }
}
//To keep the count accurate, lets get rid of prefetching
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
function wpb_track_post_views ($post_id) {
    if ( !is_single() ) return;
    if ( empty ( $post_id) ) {
        global $post;
        $post_id = $post->ID;   
    }
    wpb_set_post_views($post_id);
}
add_action( 'wp_head', 'wpb_track_post_views');

function wpb_get_post_views($postID){
    $count_key = 'wpb_post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
        return "0 View";
    }
    return $count.' Views';
}

Tuesday, February 5, 2019

Limiting Access to WordPress With Code

https://premium.wpmudev.org/blog/limit-access-to-your-wordpress-dashboard/
add_action( 'init', 'blockusers_init' );
function blockusers_init() {
if ( is_admin() && ! current_user_can( 'administrator' ) &&
! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
wp_redirect( home_url() );
exit;
}
}

Featured Post

Make money online

https://www.wpbeginner.com/beginners-guide/make-money-online/?fbclid=IwAR0_9_5aHmbB4rDisaPevdnO4uAgo0N9heHgPu1TjerjurE5ilD2NyzeB2A

Popular Posts