Ze'ev Schurmann
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: Trying to Sort Brands by Order in _termmeta tableThanks again, I used what you suggested, and now my icons are displaying in the order I want.
$classifications = wp_get_post_terms($product->get_id(), 'product_brand');
if (!empty($classifications) && !is_wp_error($classifications)) {
// Fetch term meta 'order' and store it in an array
foreach ($classifications as $key => $term) {
$order = get_term_meta($term->term_id, 'order', true);
$classifications[$key]->order_value = $order ? intval($order) : PHP_INT_MAX; // Default to max value if not set
}
// Sort terms based on order value
usort($classifications, function ($a, $b) {
return $a->order_value <=> $b->order_value;
});
// Now $classifications contains terms in the order defined in wp_termmeta
echo '<p class="product_classification"><strong>Classification: </strong><div style="display: flex; flex-wrap: wrap; gap: 7px; justify-content: center;">';
foreach ($classifications as $classification) {
$classification_url = get_term_link($classification);
$thumbnail_id = get_term_meta($classification->term_id, 'thumbnail_id', true);
$classification_description = $classification->description;
$image_url = $thumbnail_id ? wp_get_attachment_url($thumbnail_id) : '';
if (!is_wp_error($classification_url) && $image_url) {
echo '<a href="' . esc_url($classification_url) . '">'
. '<img src="' . esc_url($image_url) . '" alt="' . esc_html($classification->name) . '" title="' . esc_html($classification_description) . '" style="width: 100px; height: 100px;">'
. '</a>';
}
}
echo '</div></p><hr/>';
}I posted my code incase it ever helps someone in the future…
- This reply was modified 1 year, 3 months ago by Ze'ev Schurmann.
Forum: Developing with WordPress
In reply to: Trying to Sort Brands by Order in _termmeta table@bcworkz
Thank you… you have answered all my questions and more… plus pointed out my foopar. I can’t believe I didn’t notice that.
There is further code after the code I shared that displays icons for each of the “brands”, but I want them in my order not alphabetical order…
Thanks again.When you find a good plug-in, you give it a good review.
Okay, it is confirmed, wp_footer() is needed for the Form to display.
Re uploaded the theme, sans my edits. It all works. Definately the wp_footer() function then.
Update: I set up Multiple Theme plugin and set the page with the form to have 2021. That worked.
I then edited the Theme footer.php to remove wp_footer() and the form was gone. Returned wp_footer() and the form is back.
Now I know everyone will say, don’t edit a Theme, create a Child Theme. Well I actually make all my changes like this, then create a New Theme altogether as I add functionality and remove what I won’t use. Besides the point.
I have been up all night trying to figure this out, so I think I am on to something.It will explain why it all worked when I did the Theme Update.
I will fiddle a bit more and update this thread.Okay, facepalm time….
After doing everything, I went into theme selection again, because I noticed the theme had an update.
I did the update, switched to my other browser and pressed F5.
We have a form.
Thank you so much for assistance, but turns out it was just a bug in the theme.- This reply was modified 3 years, 4 months ago by Ze'ev Schurmann. Reason: Marking as resolved
First I tried removing all my custom css from the theme, cleaned out site data in the browser. No change.
Then I switched to a different theme and the form is there… so it’s clearly a theme related issue.The problem is I really want to use the theme I chose as it has the look and feel I want. So I will have to comb through it and see where the conflict is.
I am going to inspect the form element now and record all the classes used for the CSS and start with that. Then I will have try make over rides in the theme I want to see if I can fix it.
Oh, and even on a different theme, if I view source code, display: hidden; is still there in the <div> section for the form. So my first assumption was very wrong.Hi Nithin
I shall do as you suggest. I have added a lot of custom css to the current theme.To start with by above you meant settings in the form, right? ie under Form > Behavior > Rendering, you tried to enable the Load form using AJAX & Prevent page caching on form pages options, and still have issues right?
That is correct.
Do you have any cache plugin enabled? Does it make it any difference if cache is cleared?
I am using Jetpack. I did try disable it with the first form attempt, but it didn’t work. I will follow your steps and report back.
- This reply was modified 3 years, 4 months ago by Ze'ev Schurmann.
- This reply was modified 3 years, 4 months ago by Ze'ev Schurmann.