How to add a new column with text fields to WooCommerce Cart List?

This requires you to override WooCommerce templates: 1) First read: Template structure & Overriding templates via a theme to understand how you can change some templates copying them to your active theme folder 2) Copy the template templates/cart/cart.php located in your Woocommerce plugin to your active theme in woocommerce/cart/cart.php (so not in a “template” subfoder). … Read more

Custom post type category not displaying category ID

get_the_category retrieve array of post categories. This tag may be used outside the loop by passing a post id as the parameter. The syntax is $categories = get_the_category( $post_id ); // Outside the loop // OR $categories = get_the_category( ); // Inside the loop Note: This function only returns results from the default “category” taxonomy. … Read more

Using featured image of blog archive page

You need to grab the ID of the page you’ve set as your Posts page in Settings > Reading in order to access its properties. To do that, check for the page_for_posts option, which returns the ID: $page_for_posts = get_option( ‘page_for_posts’ ); if ($page_for_posts && has_post_thumbnail($page_for_posts) { $thumb_id = get_post_thumbnail_id( $page_for_posts); $url = wp_get_attachment_url( $thumb_id … Read more

A $_POST should occur when submit form but is not?

Add this to functions.php add_action(‘wp_ajax_post_language’,’post_language’); and then make either of following changes in your code. Because your jquery code is sending FirstNM to server (not FirstName). Therefore in post_language() function, change this line $FirstName = isset( $_POST[‘FirstName’] ) ? $_POST[‘FirstName’] : ”; to $FirstName = isset( $_POST[‘FirstNM’] ) ? $_POST[‘FirstNM’] : ”; OR Change ‘FirstNM’: … Read more

I can’t update my data through $wpdb

You’re missing your where statement. You need to tell wpdb which row it should be updating, otherwise you’re looking to insert rather than update. From the $wpdb::update Codex: wpdb->update( string $table, array $data, array $where, array|string $format = null, array|string $where_format = null );

PHP error when using newer PHP versions

Please try to change that line to comment_form( array( ‘fields’ => $fields, ‘label_submit’ => esc_attr__( ‘Submit’, ‘Divi’ ), ‘title_reply’ => ‘<span>’ . esc_attr__( ‘Leave a comment’, ‘Divi’ ) . ‘</span>’, ‘title_reply_to’ => esc_attr__( ‘Leave a Reply to %s’, ‘Divi’ ), ‘class_submit’ => ‘submit et_pb_button’, ‘comment_notes_before’

How to get category name or ID by post?

Please try below updated code <?php $recent_posts = wp_get_recent_posts(array( ‘post_status’ => ‘publish’, ‘cat’ => ”, )); foreach($recent_posts as $post) : ?> <div class=”card”> <div class=”card-bg”> <div class=”card-cat”> <?php $category_detail=get_the_category($post[‘ID’]);//Pass POST ID foreach($category_detail as $cd){ echo $cd->cat_name.”; } ?> </div> <img class=”card-img” src=”https://wordpress.stackexchange.com/questions/337072/<?php echo get_the_post_thumbnail_url( $post[“ID’] ); ?>”> </div> <div class=”card-body”> <div class=”card-title”> <?php echo $post[‘post_title’] … Read more

Conditional multidimensional arrays and array_map

returns with an error (array_map(): Argument #2 should be an array), as no array is present The $states[‘s_bib_source_c_bib_sources’] ?? [] is only setting $states[‘s_bib_source_c_bib_sources’] if it isn’t already set. If it’s set and it’s not an array, then array_map would throw the “should be an array” error. So you might better off use type-casting: isset( … Read more