Question #3 – WP CLI Quiz

$ wp post update $(wp post list –post_type=page –post_status=published –format=ids) —-meta_input='{“upgraded”:true}’

Question #2 – WP Endpoint Quiz

add_action( ‘wp_ajax_add-notifier-email’, ‘add-notifier-email’ );add_action( ‘wp_ajax_nopriv_add-notifier-email’, ‘add-notifier-email’ ); function add-notifier-email(){$company_id=$_POST[‘company_id’];$email=$_POST[’email’];$field_key = “email_notifiers”; $value = get_field($field_key, $company_id);$value[] = array(“email” => $email);;update_field( $field_key, $value, $company_id )die;}

Question #1 – WP_Query Quiz

$args = array( ‘post_type’ => ‘company’, ‘meta_query’ => array( ‘relation’ => ‘AND’, ‘sponsoreds’ => array( ‘key’ => ‘sponsored’, ‘value’ => 1, ‘compare’ => ‘=’, ), ‘rankings’ => array( ‘key’ => ‘ranking’, ‘compare’ => ‘EXISTS’, ), ), ‘orderby’ => array( ‘sponsoreds’ => ‘ASC’, ‘rankings’ => ‘ASC’, ), ); $loop = new WP_Query( $args );

Bootstrap Walker menu

$defaults = array( ‘theme_location’ => ‘primary’, ‘menu’ => ‘main-menu’, ‘container’ => ‘ul’, ‘container_class’ => ”, ‘container_id’ => ”, ‘menu_class’ => ‘nav navbar-nav’, ‘menu_id’ => ”, ‘echo’ => true, ‘fallback_cb’ => ‘wp_page_menu’, ‘before’ => ”, ‘after’ => ”, ‘link_before’ => ”, ‘link_after’ => ”, ‘items_wrap’ => ‘%3$s’, ‘depth’ => 3, ‘walker’ => new WP_Bootstrap_Navwalker() ); wp_nav_menu(…

Related post by category or similar post

ID); if ($categories) { $category_ids = array(); foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id; $args=array( ‘category__in’ => $category_ids, ‘post__not_in’ => array($post->ID), ‘posts_per_page’=> 2, // Number of related posts that will be shown. ‘caller_get_posts’=>1 ); $my_query = new wp_query( $args ); if( $my_query->have_posts() ) { echo ‘ Related Posts ‘; while( $my_query->have_posts() ) { $my_query->the_post();?> <a href="”…

Use WP functions outside of WordPress

<?php define(‘WP_USE_THEMES’, true); /** Loads the WordPress Environment and Template */ require (‘./blog/wp-load.php’); get_header(); ?>

PayUBiz Getting back shopping cart items after order fails

Follow path app/code/community/PayUbiz/PayUbiz/controllers and find $order = Mage::getModel( ‘sales/order’ )->loadByIncrementId( $session->getLastRealOrderId() ); if( $order->getId() ) $order->cancel()->save(); $this->_redirect(‘checkout/cart’); And Replace with below code. // Cancel order $order = Mage::getModel( ‘sales/order’ )->loadByIncrementId( $session->getLastRealOrderId() ); if( $order->getId() ) { $order->cancel()->save(); $cart = Mage::getSingleton(‘checkout/cart’); $items = $order->getItemsCollection(); foreach ($items as $item) { try { $cart->addOrderItem($item); } catch (Mage_Core_Exception $e){…

how to get child page in wordpress

<?php $args = array( ‘post_parent’ => 680, ‘post_type’ => ‘page’, ‘numberposts’ => -1, ‘post_status’ => ‘publish’ ); $children = get_children( $args,ARRAY_A ); $rekeyed_array = array_values($children); $childrens = $rekeyed_array[0]; foreach($children as $childrens){?> <li><a href=”<?php echo esc_url( get_permalink($childrens[‘ID’]) ); ?>”><span><?php echo $childrens[‘post_title’];?></span> </a></li> <?php } ?>

How to add Custum Currency symbol in woocommerce

global $woocommerce; if ( isset( $woocommerce ) || ! function_exists( ‘WC’ ) ) { function addINR($currency_array){ $currency_array[‘INR’] = ‘ ‘; return $currency_array; } add_filter(‘woocommerce_currency_symbols’,’addINR’); }

How to change the default Mystery Man gravatar with own images?

add this code to functions.php of the theme: add_filter( ‘avatar_defaults’, ‘newgravatar’ ); function newgravatar ($avatar_defaults) { $myavatar = get_bloginfo(‘template_directory’) . ‘/images/own-gravatar.jpg’; $avatar_defaults[$myavatar] = “Own”; return $avatar_defaults; }