itsViney
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: Using Query Loop Block to show related posts?Thank you both. If I was going to be handing this one off to a client I would probably create a variation and take that approach but for this, I’ve used the pre_get_posts hook. For anyone else trying to achieve something similar, here’s what I did…
function modify_related_query_loop_block($query) {
if (!is_admin()) {
// This is the specific query configured on the Query Loop block in the Related Messages section
if ($query->get('post_type') == 'page' && $query->get('orderby') == 'title' && $query->get('order') == 'DESC') {
global $post;
if ($post) {
$terms = wp_get_post_terms($post->ID, 'message-topic');
$term_ids = [];
foreach ($terms as $term) {
$term_ids[] = $term->term_id;
}
$query->set('post_type', 'location');
$query->set('orderby', 'rand');
// Exclude the current post
$query->set('post__not_in', array($post->ID));
if (!empty($term_ids)) {
add_filter('posts_clauses', function ($clauses, $wp_query) use ($term_ids) {
global $wpdb;
$term_ids_in = implode(',', array_map('intval', $term_ids));
$clauses['join'] .= "
LEFT JOIN (
SELECT object_id, COUNT(*) as term_count
FROM $wpdb->term_relationships
WHERE term_taxonomy_id IN ($term_ids_in)
GROUP BY object_id
) as term_matches
ON $wpdb->posts.ID = term_matches.object_id
";
$clauses['orderby'] = 'term_matches.term_count DESC, ' . $clauses['orderby'];
return $clauses;
}, 10, 2);
}
}
}
}
}
add_action('pre_get_posts', 'modify_related_query_loop_block');- This reply was modified 3 months, 3 weeks ago by itsViney. Reason: Marking as resolved
- This reply was modified 3 months, 3 weeks ago by Steven Stern (sterndata).
Forum: Developing with WordPress
In reply to: Using Query Loop Block to show related posts?Thanks @bcworkz, that’s a good suggestion. I guess it doesn’t really matter what query vars I set on the block in the editor since I can adjust them to whatever I actually need through the hook. I’ll just set them to something I’m not going to use anywhere else.
Thanks!
Forum: Plugins
In reply to: [Advanced Custom Fields: Font Awesome Field] Sharp Icon Support?Hi Matt. Just wanted to chime in and first say thanks for your hard work on the plugin, and also to add my +1 for sharp icon support. Hope you’re able to find a solution that doesn’t require too much upheaval.
Just adding a +1 to this. I’m a developer on a site where I don’t speak the site’s default (visitor-facing) language but I have my profile language set to English. WordPress and all the other plugins I have installed use the language I have set on my profile, but Wordfence uses the site language.
Thanks Adam. The ACF fields are on an options page so they’re effectively globals, not linked to a specific page or user.
I have it set up with a start and end date inside a repeater field so the user can enter as many closure periods as they need. ACF returns this as a nested array. If one of your Devs was able to provide an example of how this could be done I’d really appreciate it. No need to worry about specifics like the field names – I’m hoping I can get the gist and whatever snippit they provide.
Thanks ??
Thanks David. Sorry, maybe I didn’t explain properly. The problem is that UpdraftPlus is translated to Arabic. The plugin seems to be detecting the site language and loading the Arabic translation for the plugin but it should be checking the WP user‘s language and respecting that instead (since it’s a back-end-focussed plugin).
I’ve done a quick screen recording to demonstrate what I’m referring to:
User profile language: English UK: https://youtu.be/EUWjzBBiKM0
User profile language: Arabic: https://youtu.be/OV6-TgFtuUYIn both of these, the site language under Settings > General isn’t being changed – it’s always set to Arabic.
As you can see, WordPress core and other plugins like All in One WP Migration display in the correct language based on what the WP user has set in their preferences, but UpdraftPlus always seems determine its language from the site’s settings under Settings > General. The fact that other plugins seem to obey the user language and UpdraftPlus doesn’t, makes me thing it’s a bug in the plugin as opposed to WP core.
Hope that makes sense.
Forum: Plugins
In reply to: [Really Simple CSV Importer] Importing into an ACF link fieldYes, but how do I seperate the url, title and target attributes? Is it like
url="https://www.google.com",title="Google",target="_blank"
or something similar?Hi. Sorry, I’ll close this one. It was actually an issue with a caching plugin that somebody changed around the same time I was disabling GDPR CC. So not your plugin’s fault after all ??
Thanks anyway.
Great! Thanks very much ??
Forum: Plugins
In reply to: [Catch Infinite Scroll] Manually call function to load more postsSorry Mahesh, I don’t think I was clear enough. I already have the trigger set to on-scroll, however the issue is that in that mode it’s listening for an actual scroll event to trigger the load. On my site, it’s possible to reach the end of the list of posts without actually scrolling…
Say there are 20 posts visible that extend beyond the height of the viewport, then the user clicks a filter and 18 of the posts disappear, leaving only 2. Now, we’re at the bottom of the post list but the user hasn’t actually scrolled anywhere and now isn’t able to scroll because the page doesn’t extend beyond the bottom of the window. There’s now no way to load more posts.
I know this is probably a very niche use case, but I was hoping to be able to write my own JS to force more posts to load at the same time as filters being applied, to avoid this scenario.
Thanks Hannah. Hope there’s some way to do this.
Forum: Reviews
In reply to: [WooCommerce Stripe Payment Gateway] Great. Seems to work fine.Useful for taking payments
Forum: Plugins
In reply to: [WooCommerce Stripe Payment Gateway] Problem with adding Apple PayI meant just remove the “.txt” part so you have a file that’s just called “test”. Also make sure it isn’t completely empty. Write “bonjour” in it or something. ??
Forum: Plugins
In reply to: [WooCommerce Stripe Payment Gateway] Problem with adding Apple PayOk, next try removing the .txt file extension and see how it handles it then. I’m wondering if your server is handling requests for certain file types differently to others.
Again, just want to say I’m no expert in this area at all – I’m just saying what I would be trying if I was in your scenario. ??