Get current url with parameters passed

Add the following custom function in functions.php file of your theme to get the page url without the clean urls function get_page_custom_link() { global $post; $link = ”; if ( ‘page’ == get_option( ‘show_on_front’ ) && $post->ID == get_option( ‘page_on_front’ ) ) $link = home_url(“https://wordpress.stackexchange.com/”); else $link = home_url( ‘?page_id=’ . $post->ID ); return $link; … Read more

Customize multisite site creation with user data

To create a basic plugin, add a directory in wp-content/plugin, then put a php file in it with the required header, and that’s it. Now, here is how to use the action : add_action( ‘wpmu_new_blog’, ‘user16975_customize_blog’, 10, 6); function user16975_customize_blog($blog_id, $user_id, $domain, $path, $site_id, $meta ){ // do not forget to select the correct blog … Read more

Redirect main domain to subdirectory

From the two .htaccess files you posted I can’t see how your site is working at all?! If you request example.com/ (the document root) then the second rule in the root .htaccess file rewrites the request directly to /subdirectory/index.html (not index.php). If /subdirectory/index.html exists then the (non-WordPress) file is served, otherwise see #2 If you … Read more

What is the purpose of storing `siteurl` in database?

Since you mention multiple environments you can manually define the site URL within your wp-config.php file define(‘WP_SITEURL’, ‘http://’ . $_SERVER[‘HTTP_HOST’] . ‘/path/to/wordpress’); define(‘WP_HOME’, ‘http://’ . $_SERVER[‘HTTP_HOST’] . ‘/path/to/wordpress’); Keep in mind that it will override what you have set in your options table. As detailed in the documentation: Setting this value in wp-config.php overrides the … Read more

Concatenate site_url and string doesn’t work

Without knowing exactly what you are trying to do, it seems you want to append query variables to the URL. WordPress has methods for handling that properly, without manual string concatenation. Look at the documentation for add_query_arg() for details: https://developer.wordpress.org/reference/functions/add_query_arg/ You can rebuild the URL and append query variables to the URL query by using … Read more