Forum Replies Created
-
AuthorPosts
-
Md. Wasim Firoz
ParticipantHello Long, Thank you so much for your great support.
I need one more help with the image.
How can I show the image on the term meta archive page? I want to display the author's image on the Author's archive page. The author name and Author description are automatically displayed but not the image which is a custom field.
Please point me to the guide or tell me the location, hook or file name where I need to add the code to retrieve the image data. Thank you.
Md. Wasim Firoz
ParticipantHello, I've submitted the login details via the given contact form link. Thank you
Md. Wasim Firoz
ParticipantHello, When I gave you my code at that time the field and database name were the same - author_single_image.
So I switched the table name to 'author_single_image_db', which existed in my code when writing this message to you. But sadly it's not working.
I am placing down my code again for your review -
function woocommerce_author_single_image() { global $product; $taxonomy = 'book-author'; if( ! taxonomy_exists( $taxonomy ) ) return; // exit $term_ids = wp_get_post_terms( $product->get_id(), $taxonomy, array('fields' => 'ids') ); foreach( $term_ids as $term_id ) { $args = [ 'storage_type' => 'custom_table', 'table' => 'author_single_image_db', // table name 'object_type' => 'term' // require to add this argument, see here https://docs.metabox.io/extensions/mb-term-meta/#getting-field-value ]; $image_id = rwmb_meta( 'author_single_image', $args, $term_id ); // if the field is single_image, no need to use the for loop $image = RWMB_Image_Field::file_info( $image_id, array( 'size' => 'thumbnail' ) ); echo '<h4>test</h4>'; echo '<img src="' . $image['URL'] . '">'; } }Here is the screenshot of the code - https://share.getcloudapp.com/6quG4B60
On the frontend the word "test" is printed but not the image.
If necessary I can give you access to the site. Please get back to me when you get a chance. Thank you.
Md. Wasim Firoz
ParticipantHello Long, I exported the code of the custom field. Please check this out -
<?php add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' ); function your_prefix_function_name( $meta_boxes ) { $prefix = ''; $meta_boxes[] = [ 'title' => __( 'Author Image', 'your-text-domain' ), 'id' => 'author-image', 'taxonomies' => ['book-author'], 'storage_type' => 'custom_table', 'table' => 'author_single_image_db', 'fields' => [ [ 'name' => __( 'Single Image', 'your-text-domain' ), 'id' => $prefix . 'author_single_image', 'type' => 'single_image', 'label_description' => __( 'Author Image', 'your-text-domain' ), 'desc' => __( 'Upload Your Image', 'your-text-domain' ), 'admin_columns' => [ 'position' => 'after name', 'sort' => true, 'searchable' => true, 'filterable' => true, ], 'columns' => 2, ], ], ]; return $meta_boxes; }Thank you
Md. Wasim Firoz
ParticipantHello, Thank you for getting back to me.
I tried the following code and tested out a few other things but nothing did the work for me. Need your help
function woocommerce_author_single_image() { global $product; $taxonomy = 'book-author'; if( ! taxonomy_exists( $taxonomy ) ) return; // exit $term_ids = wp_get_post_terms( $product->get_id(), $taxonomy, array('fields' => 'ids') ); foreach( $term_ids as $term_id ) { $args = [ 'storage_type' => 'custom_table', 'table' => 'author_image_db', // table name 'object_type' => 'term' // require to add this argument, see here https://docs.metabox.io/extensions/mb-term-meta/#getting-field-value ]; $image_id = rwmb_meta( 'author_single_image', $args, $term_id ); // if the field is single_image, no need to use the for loop $image = RWMB_Image_Field::file_info( $image_id, array( 'size' => 'thumbnail' ) ); echo '<img src="' . $image['url'] . '">'; } }Could you please help me to fix it? It's holding me back for the next steps. Thank you
Md. Wasim Firoz
ParticipantHello brother, Thank you for getting back to me. I need your help. Let me explain you the scenario here -
First of all I've gone through multiple documents including your given link but I couldn't make it work.
I have a taxonomy for the author. I've created 1 custom field which is displayed in the author's taxonomy.
This custom field is for uploading a single image and saved in a custom database. The author taxonomy data will be selected from any woocommerce product.
On the front-end on any woocommerce product page under a tab I want to display this image if that product has that taxonomy selected. I've tried both following codes for retrieving image but it;s not working
<?php $price = rwmb_meta( 'price', ['storage_type' => 'custom_table', 'table' => 'properties'], 15 ) ?> <p> <strong>Property price:</strong> <?= number_format( $price ) ?> USD </p>$args = [ 'storage_type' => 'custom_table', 'table' => $table_name, ]; $value = rwmb_meta( $field_id, $args, $post_id ); echo $value;By the way, this is working for me when I am saving the custom field data into the default database.
function woo_author_details_tab_content() { global $product; $taxonomy = 'book-author'; // <== Here set your custom taxonomy if( ! taxonomy_exists( $taxonomy ) ) return; // exit $term_ids = wp_get_post_terms( $product->get_id(), $taxonomy, array('fields' => 'ids') ); foreach($term_ids as $terms) { $term_id = $terms; } if ( ! empty($term_ids) ) { $image=""; foreach($term_ids as $terms) { $term_id = $terms; $image_ids = get_term_meta( $term_id, 'author_image_db', false ); foreach ( $image_ids as $image_id ) { $image = RWMB_Image_Field::file_info( $image_id, array( 'size' => 'thumbnail' ) ); echo '<img style="border-radius: 10px;" src="' . $image['url'] . '"><br />'; } } } }Please help me to retrieve the image and display it from the custom table. I badly need this help. Thank you in advance 🙂
October 17, 2022 at 3:23 PM in reply to: Unable to display a custom field on Woocommerce Product page #38705Md. Wasim Firoz
ParticipantBy the way, I've already checked out this documentation - https://metabox.io/plugins/mb-custom-table/
I am confused by this sentence - This reduces the number of rows in the database which can cause a performance issue when the data grows.
Could you please clarify this?
If I plan to have 20,000+ products with a few custom fields enabled, will it be a good decision to use a Custom table instead of the default table?
Performance is very important so please suggest to me the best option to follow. Thank you
October 17, 2022 at 11:31 AM in reply to: Unable to display a custom field on Woocommerce Product page #38696Md. Wasim Firoz
ParticipantHello Long, Thank you for your reply.
I was wondering where the data inserted using the custom field is saved in the database.
Is it a good idea to create a separate database for every custom field using this option - Save data in a custom table?
Thank you
October 16, 2022 at 6:26 PM in reply to: Unable to display a custom field on Woocommerce Product page #38684Md. Wasim Firoz
ParticipantHello Long Nguyen, Thanks for your prompt reply. Following the solution provided on your given link, I was able to display the Value of a custom field on the front end but how can I display the value in the exact location where it should be?
In my case, I want to display a subtitle underneath the product title (Not in the short description area). In the filed setting I am choosing the option - After post title
But the value is not being displayed underneath the title.
I am entering the hook using a snippet plugin. Help me out when you get a chance. Thank you.
April 6, 2021 at 9:05 PM in reply to: ✅How can I show a custom field as a column in a taxonomy? #27000Md. Wasim Firoz
ParticipantHello, I've already installed this plugin but how this works it's confusing to me. If I install and activate Meta Box AIO then do I need to install each extension seperately?
for some reason, I am unable to display the custom field in the taxonomy column! I am not sure what I am doing wrong? Could you give me a push to get it done? Thank you.
-
AuthorPosts