Skip to main content

Posts

Showing posts from 2019

get custom posts with pagination

   $the_query = new WP_Query( array('posts_per_page'=>30,                                  'post_type'=>'abc',                                  'paged' => get_query_var('paged') ? get_query_var('paged') : 1)                             );                             ?> <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?> <div class="col-xs-12 file">...

Toolset conditional

[wpv- if evaluate= "'[wpv-current-user info='id']' = '[wpv-post-author format='meta' meta='ID']' OR '[wpv-current-user info='role']' = 'administrator'" ]      //the content you want to hide goes here [/wpv- if ]

Call posts using query

$args = array (      'post_type' => 'post' ,      'tax_query' => array (          'relation' => 'OR' ,          array (              'taxonomy' => 'category' ,              'field'     => 'slug' ,              'terms'     => array ( 'quotes' ),          ),          array (              'taxonomy' => 'post_format' ,              'field'     => 'slug' ,        ...

get user role by shortcode

function get_user_role_func( $atts ) {   $a = shortcode_atts( array(       'userid' => ''   ), $atts );   $userdata = get_user_by('ID', $a['userid']);   $user_roles = $userdata->roles;   $user_role = array_shift($user_roles);   return $user_role; } add_shortcode( 'get_user_role', 'get_user_role_func' ); [get_user_role userid="[wpv-user field='ID']"]

add masnory view to photos

<script src="https://masonry.desandro.com/v2/jquery.masonry.min.js"></script> <div class="video-collection">        <div class="video-box">                   <img src="abc.jpg">        <div> </div> <style> .video-collection .video-box {     width: 234px;     float: left;     border: 1px solid #ccc;     margin: 1%; } </style> <script> jQuery(document).ready(function($){     var container = $('.video-collection');     container.imagesLoaded( function(){           container.masonry({             itemSelector : '.video-box'           });     });...

Logout without confirmation wordpress

add_action('check_admin_referer', 'logout_without_confirm', 10, 2); function logout_without_confirm($action, $result) {     /**      * Allow logout without confirmation      */     if ($action == "log-out" && !isset($_GET['_wpnonce'])) {         $redirect_to = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : site_url();         $location = str_replace('&amp;', '&', wp_logout_url($redirect_to));         header("Location: $location");         die;     } }

simplest working ajax code in wordpress

i n file anywhere in script tag var data = {                             'action': ' staple_dist ',                             'wpcf-preis-km-8-meter-bus': values                         };                                                 var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';                         $.post(ajaxurl, data, function(response) {             ...

AJAX single file upload wordpress

< form method = "post" enctype = "multipart/form-data" >     < div class = "form-group" >        < label >Choose File:</ label >        < input type = "file" id = "file" />     </ div > </ form >   <script>      var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>" ;      jQuery( function ($) {          $( 'body' ).on( 'change' , '#file' , function () {              var file_data = $(this).prop( 'files' )[0];              var form_data = new FormData();              form_data.append( 'file' , file_data);      ...

Build Your Own Ajax Contact Form in WordPress

page.php < div id = "contact_form" >         < div id = "result" >< / div >         < div class = "form-group" >         < label for = "name" > Name < / label >         < input type = "text" name = "name" class = "form-control input-name" placeholder = "Enter Your Name" / >     < / div >     < div class = "form-group" >         < label for = "email" > Email < / label >         < input type = "email" name = "email" class = "form-control input-email" placeholder = "Enter Your Email" / >     < / div >       < div class = "form-group" >         < label for = "message" > Message < / label >           < textarea name = "message" class ...

WordPress Front-end AJAX Pagination with Search and Sort

Step 1 : Create a custom page in WordPress Go to your Dashboard > Pages > Add New Name the page anything you want, ex: My Posts In your Dashboard > Settings > Permalinks, make sure Common Settings is set to Post Name In your newly created page, copy the page slag: if you used “My Posts” as your page name, the slag would be my-posts In your WordPress theme create a file called page- my-posts .php  Notice how we attached the slag to the “ page- “, this will allow us to add custom scripts that will only apply to this specific page. Go to your browser and navigate to your new page. ex. http://example.com/ my-posts It should show you a blank white page , if not then you did something incorrectly. <link rel="stylesheet" href=" https :// maxcdn . bootstrapcdn . com / bootstrap / 3 . 3 . 5 / css / bootstrap . min . css " />  ---Open the new page and paste the following code template: <?php get_header(); ?>     <div class ...