Create custom url which executes code (not render render a WordPress entity)?

You can achieve this with a rewrite rule, you just need to exit execution before the main query is run. First, add a query var that will get set by the rewrite rule: function wpd_query_vars( $query_vars ){ $query_vars[] = ‘my_var’; return $query_vars; } add_filter( ‘query_vars’, ‘wpd_query_vars’ ); Next, the rewrite rule: function wpd_rewrite_rule(){ add_rewrite_rule( ‘^my-url/?$’, … Read more

Two sets of url one content?

You can create custom post type to manage your secondary content (multilanguage i suppose) and set these /fr/ your CPT rewrite base. Create a CPT function add this to your function. $rewrite = array( ‘slug’ => ‘fr’, ‘with_front’ => false, ‘pages’ => true, ‘feeds’ => true, ); After that set CPT rewrite option to rewrite … Read more

Show Mysql table elements as pages in WordPress

To do that, create custom post type to store info. You do not need to create any custom table as your every record will be saved as a unique post in your custom post type. For detailed assistance, please have a look at the documentation here: https://codex.wordpress.org/Function_Reference/register_post_type Let us know if there is any confusion. … Read more

How can I create custom URL routes?

Add this to your theme’s functions.php, or put it in a plugin. add_action( ‘init’, ‘wpse26388_rewrites_init’ ); function wpse26388_rewrites_init(){ add_rewrite_rule( ‘properties/([0-9]+)/?$’, ‘index.php?pagename=properties&property_id=$matches[1]’, ‘top’ ); } add_filter( ‘query_vars’, ‘wpse26388_query_vars’ ); function wpse26388_query_vars( $query_vars ){ $query_vars[] = ‘property_id’; return $query_vars; } This adds a rewrite rule which directs requests to /properties/ with any combination of numbers following to … Read more

Using a Rewrite URL in a Plugin to Load a New Page in the Template

add_rewrite_rule( $regex, $redirect, $after ); Rewrite rules to scripts other than index.php The $redirect argument works slightly differently when redirecting to a custom PHP script because WordPress delegates these redirects to .htaccess instead of processing them itself. For this reason, querystring variables should be written like $1 instead of $matches[1]. Personally, I would use a … Read more

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