Skip to main content

Posts

Showing posts from August, 2021

How to get product categories in product loop in Woo-commerce?

Get product categories in product loop in Woo-commerce. add_action('woocommerce_shop_loop_item_title', 'pendingcategory');     function pendingcategory(){ global $product; $id = $product->get_id(); $terms = wp_get_post_terms( $id, 'product_cat' ); foreach ( $terms as $term ) { $categories[] = $term->slug; } if ( in_array( 'pending', $categories ) ) {   echo 'Pending'; } }   

How to add "wp_editor" in custom form in Wordrpess?

Add "wp_editor" in custom form in Wordrpess. if(isset($_POST['submit'])){ print_r($_POST); } $editor_id = 'custom_editor_box'; $uploaded_csv = 'hello'; ?> <form action="" method="post"> <?php  wp_editor( $uploaded_csv, $editor_id ); ?> <input type="submit" value="submit" name="submit"> </form> <?php

How to build a tree from a flat array in PHP>

Build a tree from a flat array in PHP   $hello = array   (   array("ID" => "1","student" => "Jassi","marks" => "80","parent_id" => ""),   array("ID" => "2","student" => "Golu","marks" => "80","parent_id" => "1"),   array("ID" => "3","student" => "Jassi","marks" => "80","parent_id" => "1"),   array("ID" => "4","student" => "Jai","marks" => "90","parent_id" => "1"),   array("ID" => "5","student" => "Jassi","marks" => "85","parent_id" => "1"),   array("ID" => "6","student" => "Ravinder",...

How to get PHP array group by key value?

“PHP array group by key value" $hello = array   (   array("ID" => "1","student" => "Jassi","marks" => "80","parent_id" => ""),   array("ID" => "2","student" => "Golu","marks" => "80","parent_id" => "1"),   array("ID" => "3","student" => "Jassi","marks" => "80","parent_id" => "1"),   array("ID" => "4","student" => "Jai","marks" => "90","parent_id" => "1"),   array("ID" => "5","student" => "Jassi","marks" => "85","parent_id" => "1"),   array("ID" => "6","student" => "Ravinder","mar...

How To Add (Create) Pagination in WordPress?

 Add (Create) Pagination in WordPress. <style> .cus_pagination ul li .page-numbers {     background: white;     padding: 7px 11px;     margin-left: 8px;     text-decoration: none;     border: 1px solid black;     color: #000; } .cus_pagination ul {     display: flex; } .cus_pagination span.page-numbers.current {     background: #000;     color: white; } </style> <?php global $wpdb; // QUERY HERE TO COUNT TOTAL RECORDS FOR PAGINATION  $cars = array   (   array("student" => "Jassi","marks" => "80"),   array("student" => "Jai","marks" => "90"),   array("student" => "Golu","marks" => "85"),   array("student" => "Ravinder","marks" => "30"),   array("student" => "Mukesh","marks" => "45"),   array("student" => "Ankush","...