Posts

Showing posts from July, 2018

custom qty and add to cart button for html to convert single product page wordpress

  <?php //do_action('woocommerce_simple_add_to_cart');                                              //  do_action('[add_to_cart]'); // echo do_shortcode( '[add_to_cart id=' . get_the_ID() . ']' );          ?>                                              <form class="cart" method="post" enctype="multipart/form-data">     <div class="quantity">         <input id="input-quantity" type="number" step="1" min="1" max="" name="quantity" value="1" title="Quantity" class="input-text qty text form-control" size="4" pattern="[0-9]*" inputmode="numeric">     </div>     <input type="hidden" name="add-to-cart" value="<?php ...

get category name info in custom post type single post page in wordpress

<?php global $post; $terms = get_the_terms( $post->ID, 'product_cat' ); foreach ($terms as $term) {   $product_cat_id = $term->term_id;         $category_link = get_category_link( $product_cat_id );     if( $term = get_term_by( 'id', $product_cat_id, 'product_cat' ) ){     $cat_name=$term->name; }   break; }

pagination for custom taxonomy in wordpress

add_action('pre_get_posts', function($query) {     if ($query->is_tax('product_cat')) {         $query->set('posts_per_page', 12);     } });

show Only Parent Categories of custom taxonomy in wordpress

 <?php                                             $taxonomy     = 'product_cat';                                             $orderby      = 'name';                                              $show_count   = 0;                                                $pad_counts   = 0;                                                $hierarchical = 1;    ...

custom woocommerce brand taxonomy in wordpress.

/* brand   */ $taxonomy_labels = array( 'name' => _x( 'Brands', 'productposttype' ), 'singular_name' => _x( 'Brand', 'productposttype' ), 'search_items' => _x( 'Search Brand', 'productposttype' ), 'popular_items' => _x( 'Popular Brand', 'productposttype' ), 'all_items' => _x( 'All Brand', 'productposttype' ), 'parent_item' => _x( 'Parent Brand', 'productposttype' ), 'parent_item_colon' => _x( 'Parent Brand:', 'productposttype' ), 'edit_item' => _x( 'Edit Brand', 'productposttype' ), 'update_item' => _x( 'Update Brand', 'productposttype' ), 'add_new_item' => _x( 'Add New Brand', 'productposttype' ), 'new_item_name' => _x( 'New Brand Name', 'productpostt...

add image option in custom taxonomy wordpress

/* Adding option in custom taxonomy for listing page   */ if( ! class_exists( 'Showcase_Taxonomy_Images' ) ) {   class Showcase_Taxonomy_Images {         public function __construct() {      //     }     /**      * Initialize the class and start calling our hooks and filters      */      public function init() {      // Image actions      add_action( 'education_type_add_form_fields', array( $this, 'add_category_image' ), 10, 2 );      add_action( 'created_education_type', array( $this, 'save_category_image' ), 10, 2 );      add_action( 'education_type_edit_form_fields', array( $this, 'update_category_image' ), 10, 2 );      add_action( 'edited_education_type', array( $this, 'updated_category_image' ), 10, 2 );      add_action( 'admin_enqueue_scripts', array( $this, '...

search result with search term with category in wordpress

<?php /**  * The template for displaying Search Results pages.  */  get_header(); ?> <?php $s = $_GET['s']; $post_type = $_GET['post_type']; $cat_terms = $_GET['cat_terms']; $category_ID = get_category_id($cat_terms);  ?>  <?php      $search_args = array( 'post_type' => 'listing', 'orderby' => 'post_date', 's' => $_GET['s'], 'posts_per_page' => -1, 'order' => 'DESC',  'post_status'  => 'publish'); $cat_args= array(             'post_type' => 'listing',             'order' => 'DESC', 'orderby' => 'post_date',             'post_status' => 'publish', 'posts_per_page' => -1,        'tax_query' => array(             array(                 'taxonomy' => 'education_type',   ...

get post count by category name in custom post type in wordpress

<?php $args = array( 'post_type' => 'listing', 'tax_query' => array( array( 'taxonomy' => 'education_type', 'field'    => 'slug', 'terms'    => $cat->name, ), ), ); $query = new WP_Query( $args );    echo $count = $query->post_count; ?>

Jquery / Javascript Solution for URL matches Href then add a Class

   <script>  jQuery(document).ready( function($){   var url      = window.location.href;       $('.service_list a').each(function(){     var href = $(this).attr('href');      if (url.indexOf(href) > -1) {           //  alert("Yes!");    $(this).addClass("active");     }  });       });  </script> https://stackoverflow.com/ questions/37996328/jquery- javascript-solution-for-url- matches-href-then-add-a-class

Show sub page specific parent page in wordpress

 <?php $args = array(     'post_type'      => 'page',     'posts_per_page' => -1,     'post_parent'    => 27,     'order'          => 'ASC',     'orderby'        => 'menu_order' ); $parent = new WP_Query( $args ); if ( $parent->have_posts() ) : ?> <ul> <li> <a>All Pricing</a></li>     <?php while ( $parent->have_posts() ) : $parent->the_post(); ?>         <li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>           ...