How to remove file versions from the file source links in wp_head?

You can hook into style_loader_src and script_loader_src and run remove_query_arg( ‘ver’, $url ) on the URL: <?php /* Plugin Name: Remove version parameter for scripts and styles */ add_filter( ‘style_loader_src’, ‘t5_remove_version’ ); add_filter( ‘script_loader_src’, ‘t5_remove_version’ ); function t5_remove_version( $url ) { return remove_query_arg( ‘ver’, $url ); } Without this plugin: After plugin activation: There is … Read more

How to call images from your plugins image folder?

Use plugin_dir_url() to get the public URI for the directory where the calling PHP file is. <img src=”https://wordpress.stackexchange.com/questions/60230/<?php echo plugin_dir_url( __FILE__ ) .”images/facebook.png’; ?>”> If the PHP file is in a sub directory of your plugin you have to go up: <img src=”https://wordpress.stackexchange.com/questions/60230/<?php echo plugin_dir_url( dirname( __FILE__ ) ) .”images/facebook.png’; ?>”>

Using custom/dynamic “slug” for a page

Create a Page Template Add a new page and give it the slug stores Add A Public Query Variable add_filter(‘query_vars’, ‘add_state_var’, 0, 1); function add_state_var($vars){ $vars[] = ‘state’; return $vars; } Add a rewrite rule This will direct your request to your stores page. add_rewrite_rule(‘^stores/([^/]*)/?’,’index.php?post_type=page&name=stores&state=$matches[1]’,’top’); Within your Template You can access your state variable as … Read more

How to get pretty URLs with add_query_arg in permalinks

Just faced the same situation and stumbled upon this question while googling. It seems like this isn’t possible. Core itself just appends strings to the URL if pretty permalinks are enabled, see https://core.trac.wordpress.org/browser/tags/3.9.1/src/wp-includes/link-template.php#L571 For anyone interested in this: You can do something like this in your code: if ( ” != get_option(‘permalink_structure’) ) { // … Read more

Disable ONLY URL auto complete, not the whole canonical URL system

Updated Answer (2020-10-29): The solution has changed with WordPress 5.5. Keeping the old answer for reference below. Short version: Get my pluign from here: https://wordpress.org/plugins/disable-url-autocorrect-guessing/ Long Version: With WordPress 5.5, you can control more precisely if/how the guessing should work. Refer to https://make.wordpress.org/core/2020/06/26/wordpress-5-5-better-fine-grained-control-of-redirect_guess_404_permalink/ for more information. To completely disable guessing, use this code: add_filter( ‘do_redirect_guess_404_permalink’, … Read more

Possible to change the URL for the regular post type without affecting the URL of other custom post types?

You could do this on custom post type registration. 1) Set your default permalink in the WordPress admin to your desired structure e.g.: /blog/%postname% 2) Add the “slug” and “with_front” parameter to the rewrite-array in the register_post_type function. “slug” must be the name of your post-type. $args = array( // … ‘rewrite’ => array( ‘slug’ … Read more

Get current URL (permalink) without /page/{pagenum}/

You can get the current URL through home_url( $wp->request ). Try the example below: global $wp; // get current url with query string. $current_url = home_url( $wp->request ); // get the position where ‘/page.. ‘ text start. $pos = strpos($current_url , ‘/page’); // remove string from the specific postion $finalurl = substr($current_url,0,$pos); echo $finalurl;

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