How to display custom fields as table in Woocommerce

How are the custom fields saved? If you use ACF – Advanced custom fields, you can use get_field() function to get the variables. This should get you started. You can use another action hook or priority if you want the table to be displayed somewhere else. function display_product_table(){ global $product; ?> <table class=”shop_attributes”> <tr> <th><?php … Read more

Pass WordPress variable to the next page

If it is working with a literal string (“example”) but not with the variable, we can assume that the issue is with your variable. You haven’t provided all of the code for that section of index.php, but as it is I do not think you can expect that variable to hold anything. First, you are … Read more

Is there a way to fetch the category of a page when using wp_list_pages?

You can get an array of pages using get_pages() and then for each page retrieve categories using wp_get_object_terms. Your code may look like this: $args = array( ‘post_type’ => ‘board-meeting’, ‘post_status’ => ‘publish’ ); $pages = get_pages($args); if ( ! empty( $pages ) ) { echo ‘<ul>’; foreach($pages as $page){ $cats = wp_get_object_terms( $page->ID, ‘category’ … Read more

Get only children category name

For this specific question, Try this $categories = get_the_category($id); foreach($categories as $category){ if($category->parent != 0){ // Display it here echo ‘<a href=”‘ . esc_url( get_category_link( $category->term_id ) ) . ‘”>’ . esc_html( $category->name ) . ‘</a>’; } }

Retrieving Categories based on the first character of the name

Found a solution. I found a function that answered my question. Here is the function: function get_category_by_letter($letter) { $args=array( ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘hide_empty’ => 0); $categories=get_categories($args); foreach($categories as $category) { $catname = $category->name; $first_letter = substr(strip_tags($catname), 0 , 1); if(strcasecmp($first_letter,$letter) != 0) continue; else { $cats[] = $category->term_id; $cats[] = $category->name; } … Read more