Rewrite Rules to custom template

Found the solution: functions.php: add_action(‘init’, ‘wp_university_full_rewrite’); function wp_university_full_rewrite() { add_rewrite_rule( ‘university/([^/]*)/?$’, ‘index.php?pagename=university&uni_name=$matches[1]’, ‘top’); } add_filter(‘query_vars’, ‘wp_university_full_query_vars’); function wp_university_full_query_vars( $query_vars ) { $query_vars[] = ‘uni_name’; return $query_vars ; } function get_data_with_query( $name_query ) { $data = []; global $wpdb; $data = $wpdb->get_row(“SELECT * FROM table WHERE name=””.$name_query.”””, ARRAY_A ); return $data; } custom_template.php: <?php $name_pull = … Read more

I have a problem in the order of enqueues while enqueuing stylesheets and scripts for a specific page in my function.php

Driss, I tend to break up css and javascript that’s specific to a template into files specifically for that template – that way if it’s not needed on every page, I’m not loading it and thus that allows me to keep my main.js and style.css smaller. Here’s how I normally do it: if( is_page_template( ‘room.php’ … Read more

Setting posts_per_page for taxonomy term template

The taxonomy template you have (taxonomy-insight_type-academia.php) is in the form of (taxonomy-{taxonomy}-{term}.php), and the format for is_tax() is is_tax( ‘<taxonomy>’, ‘<term>’ ), so in your pre_get_posts callback, you should: // Use this. if ( $query->is_tax( ‘insight_type’, ‘academia’ ) ) // Not this. if ( $query->is_tax( ‘academia’, ‘insight_type’ ) ) Additionally — to avoid conflict with … Read more

How to get custom page template being edited in gutenberg editor

You can use this code once set page template for specific post. If the template isn’t set, you cant enqueue your script. if ( $post->_wp_page_template === ‘sky-template.php’ ) { wp_enqueue_script(); } Remember to replace sky-template.php with your template file name. Edit: You can get some help from this question. _wp_page_template to dynamically use template