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

add_rewrite_rule with query variables

First of all, Your code does not work because rewrite rules need to be flushed ( function flush_rewrite_rules ), and they need to be flushed for every $id change. Generally this is very bad idea, for performance reasons. You should add rewrite rule only with post_type=product, as You want to pass “p” as $_GET parameter … Read more

Create Dynamic SEO Friendly URL for Virtual Page

One approach could be to create a rewrite rule that will catch the 3 variables and provide them as parameters that can be passed on to your job template. Assuming your template slug is “job”: function jobquery_rewrite_rule() { add_rewrite_rule( ‘^job/([^/]*)/([^/]*)/([^/]*)/?’, ‘index.php?pagename=job&state=$matches[1]&city=$matches[2]&job=$matches[3]’, ‘top’ ); } add_action( ‘init’, ‘jobquery_rewrite_rule’ ); After inserting this action into your theme, … Read more

URL Rewriting for PHP script on an image URL

Try the following at the top of the .htaccess file, before the existing WordPress directives: # Internally rewrite “/image.jpg” to “/randomizer.php” RewriteRule ^image\.jpg$ randomizer.php [L] This uses mod_rewrite to rewrite the URL. There is no need to repeat the RewriteEngine On directive (that occurs later in the file). Any request for /image.jpg (in the document … Read more

Can’t get custom rewrite tag, query var, permastruct (permalink structure), and rewrite rule to work properly together

After a lot of inspection of rewrites happening under the hood by hooking into filters and logging variable values, I managed to solve the problem! Queries and query rewriting When a query occurs, WordPress will serve the content using the correct template as soon as it has enough info to unambiguously determine what the template … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)