Combining two select posts from mysql – to get least viewed posts

This should be the SQL you’re looking for (off the top of my head, so may need some tweaking). “SELECT * FROM wp_posts LEFT JOIN wp_popularpostsdata ON (wp_posts.ID = wp_popularpostsdata.postid) LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) LEFT JOIN wp_term_taxonomy ON (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id) WHERE posts.post_type=”post” AND wp_term_taxonomy.term_id NOT IN (73) GROUP BY wp_posts.ID ORDER … Read more

How to add translation for FSE theme?

Could you please cross check lexiadesign is the correct Text Domain of your FSE theme. Agter this you can use given functions for Internationalization of Strings of your theme or plugin. esc_html__() : This is used to translate and escape HTML attributes. For Ex. <?php echo esc_html__(‘Download Lexia’, ‘your-theme-textdomain’); ?> esc_html_e() : This is used … Read more

WooCommerce: Custom dropdown for variation selection

I think the condition here has_term($term_slug, $taxonomy, $variation->get_id()) won’t work for variation. If you want to check term, we need to check with parent variable product instead of checking variation because Woocommerce doesn’t store any taxonomy/term attribute to variation. Instead of using has_term, we can use your existing attributes in get_variation_attributes to get and check … Read more

Hook before DB connection is made

The problem with having a “hook” is that the add_action() function would not be defined that early so WordPress would have to be recoded so that the function is available much earlier. Also to use an action hook you would need to add your code inside a theme or a plugin. WordPress must make database … Read more

Exclude category when displaying all categories assigned to a post

get_the_category() has a filter, get_the_categories, that will filter the categories. You can do something like this: add_filter( ‘get_the_categories’, ‘wpse426499_filter_categories’ ); /** * Filters the categories. * * @param WP_Term[] $categories An array of WP_Term (ie, category) objects. * @return WP_Term[] The filtered array of WP_Term objects. */ function wpse426499_filter_categories( $categories ) { $undesired_id = 2; … Read more