New answers tagged

0

Refer Link for Your Knowledge Template Hiearchy for a more detailed break down of how WordPress chooses the template For a taxonomy term slug ('sports' your example) in the taxonomy (e.g. 'News') WordPress will try to use the following templates (in this order) taxonomy-{taxonomy}-{slug}.php taxonomy-{taxonomy}.php taxonomy.php archive.php index.php Modify ...


0

You could setup a redirect at the top of the archive page template for users that don't match your criteria, something like: $user = wp_get_current_user(); $allowed = array( 'editor', 'administrator' ); $redirect_url = 'https://url-to-redirect-to'; if ( ! $user || ! array_intersect( $allowed, $user->roles ) ) { wp_safe_redirect( $redirect_url, 401 ); ...


2

This is for Algerian wilayas & communes, for the full code check this repo: https://github.com/ilyesrd/Insert-Wilayas-Communes-to-custom-taxonomy-in-wordpress add_action('init', 'add_wilayas_and_communes', 100); function add_wilayas_and_communes() { $communes = array( // Take a look to this repo: https://github.com/ilyesrd/Insert-Wilayas-...


0

I know that this is an old post, but I just wanted to chime in. @jdm2112 is correct. Just use the WP_Query class. This makes sure that if the database structure is ever updated in the future, your query still works.... However, since it looks like you are looking for a raw SQL answer, this is the actual SQL that WP_Query would execute... at least as of ...


0

Knowledge The filter title_save_pre runs before the post is written to the database, and also before any of its post meta is saved to the database. wp_get_object_terms at this point will be blank. To correct this you'll want to hook into save_post and update the post from there. save_post runs after the post has been saved to the database, and the in-...


0

I have also search for this but did not find solution, @harisrozak solution is great, but I need to also use order by. so I had develop custom query for that as below. function searchterm(){ global $wpdb; $search_query = sanitize_text_field($_GET['q']); $query = "SELECT DISTINCT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_termmeta ON ( t.term_id = ...


1

This post provides a function, but it cannot handle non-latin characters. That's because URLs can't have non-latin/ASCII characters. Browsers might show non-latin characters to you, but it's just a user interface feature. For example, if you visit this Wiktionary URL: https://en.wiktionary.org/wiki/わかもの#Japanese, you browser URL encodes the japanese ...


0

ok this is how I solved it: //1. Get all events with meta field $args = [ 'post_type' => "events", 'posts_per_page' => -1, 'meta_query' => [ [ 'key' => 'event_archive', 'value' => "true", 'compare' => '!=' ...


Top 50 recent answers are included