Posts

Showing posts from May, 2018

GET ALL CATEGORIES IN WOOCOMMERCE

<?php $taxonomy = 'product_cat'; $orderby = 'name'; $show_count = 0; // 1 for yes, 0 for no $pad_counts = 0; // 1 for yes, 0 for no $hierarchical = 1; // 1 for yes, 0 for no $title = ''; $empty = 0; $args = array( 'taxonomy' => $taxonomy, 'orderby' => $orderby, 'show_count' => $show_count, 'pad_counts' => $pad_counts, 'hierarchical' => $hierarchical, 'title_li' => $title, 'hide_empty' => $empty ); $all_categories = get_categories( $args ); foreach ($all_categories as $cat) { $thumbnail_id = get_woocommerce_term_meta($category_id, 'thumbnail_id', true ); $image = wp_get_attachment_url( $thumbnail_id ); echo $cat->name; echo $cat->description; echo esc_url( get_term_link( $cat ) ); if($cat->category_parent == 0) { $category_id = $cat->term_id; echo '<br />...

Custom filed for specific page templae in wordpress

/*Custom filed for specific page templae (about us)   */ function wpse70958_add_meta_boxes( $post ) { global $post; $page_template = get_post_meta( $post->ID, '_wp_page_template', true ); if ( 'about-page-template.php' == $page_template ) {      add_meta_box( 'about_meta', 'About Details', 'about_meta_functions', 'page', 'normal', 'high' ); } } add_action( 'add_meta_boxes_page', 'wpse70958_add_meta_boxes' ); function about_meta_functions() {         global $post;               $our_mission= get_post_meta($post->ID, 'our_mission', true); $our_vission= get_post_meta($post->ID, 'our_vission', true); ?> <div class="row"> <div class="form-group col-sm-12">     <label for="our mission" style="vertical-align:top;">Our Mission</label>             <textarea rows="4" cols="100...

guideline custom post type with multple fields in wordpress

<?php add_action( 'init', 'guideline' ); function guideline(){ register_post_type( 'guideline',     array(         'labels' => array(             'name' => __( 'Guidelines' ),             'singular_name' => __( 'Guideline' ),             'menu_name' => __( 'Guidelines' ),             'all_items' => __( 'All Guidelines' ),             'add_new' => __( 'Add New Guidelines' ),             'add_new_item' => __( 'Add New Guidelines' ),             'edit_item' => __( 'Edit Guideline' ),             'new_item' => __( 'New Guideline' ),             'view_item' => __( 'View Guideline' ),             'search_items' => ...

bootstrap portfolio using custom post type

 <div class="main"> <div id="myBtnContainer">  <?php $taxonomy = 'ourprojects_category'; $terms = get_terms($taxonomy); if ( $terms && !is_wp_error( $terms ) ) : ?>                  <button class="btn active" onclick="filterSelection('all')"> Show all</button>     <?php foreach ( $terms as $term ) { ?>                                                  <button class="btn" onclick="filterSelection('<?php echo $term->slug; ?>')"> <?php echo $term->name; ?></button>                                                 <?php } ?>        <?php endif;?...

display categories of my Custom Post Type

<?php $taxonomy = 'portfolio_categories'; $terms = get_terms($taxonomy); // Get all terms of a taxonomy if ( $terms && !is_wp_error( $terms ) ) : ?>     <ul>         <?php foreach ( $terms as $term ) { ?>             <li><a href="<?php echo get_term_link($term->slug, $taxonomy); ?>"><?php echo $term->name; ?></a></li>         <?php } ?>     </ul> <?php endif;?> ?>