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;

Add .html (dot HTML) extension to custom post types

This seem to work: Create the rewrite rules like post-type/post-name.html. You can use arrays to create the rules for just some set of post types instead of doing it for all of them. add_action( ‘rewrite_rules_array’, ‘rewrite_rules’ ); function rewrite_rules( $rules ) { $new_rules = array(); foreach ( get_post_types() as $t ) $new_rules[ $t . ‘/([^/]+)\.html$’ … Read more

Filter any HTTP request URI?

Less than an answer, but just a list of things straight from my experience with it – maybe you’ve overlooked something. Debugging the request & its results Without diggin’ too deep into the update process, but the WP HTTP API uses the WP_HTTP class. It also offers a nice thing: A debug hook. do_action( ‘http_api_debug’, … Read more

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş