What is the term shortlink structure?

Well if you are referring to what are the query string keys are, it will depend on the taxonomy you are working with, for categories: you are looking for ?cat=cat_id tags: you are looking for ?tag=tag_slug custom taxonomy: it depends on the slug of the tax but it will look like ?taxonomy_slug=item_slug Check the definition … Read more

Using API to generate short link

You never need do_shortcode(), better said, almost never, there are a few cases where do_shortcode() could be appropiate. Note how you could do just: echo shorten_url( ‘http://mylink.com ‘ ); instead of: echo do_shortcode(‘[shorten]http://mylink.com[/shorten]’); Think about shortcodes as PHP functions placeholders; they are intended to be use where you can not execute PHP directly, like the … Read more

Short links in wordpress not working properly

Shortlinks are not natively supported by WordPress. What you are calling a shortlink (the one ending in ?p=123) is actually the standard permalink, based on the post ID. Shortlinks encrypt the actual permalink, which may as elaborate as you mention in your first example. External services such as Jetpack (wp.me) and Bitly (bit.ly) will take … Read more

Create additional short URL with custom field and 301 redirect

The first step is the rewrite rule. I’ve also added a rewrite tag so the custom query var will be parsed. You can also use the query_vars filter for this instead. add_action( ‘init’, ‘tipp_rewrite_rule’ ); function tipp_rewrite_rule() { add_rewrite_tag( ‘%trick_nummer%’, ‘([a-zA-Z0-9]+)’ ); add_rewrite_rule( ‘^tipp([a-zA-Z0-9]+)?’, ‘index.php?trick_nummer=$matches[1]’, ‘top’ ); } The second step is to intercept these … Read more

Change link to other post to shortlink in the editor

The links in that dialog are made by wp_ajax_wp_link_ajax() (see wp-admin/includes/ajax-actions.php, there is no page on Codex or queryposts.com for that function). To change the links filter ‘page_link’, ‘post_type_link’, ‘post_link’ and maybe ‘attachment_link’ after check_ajax_referer() was called for the action ‘internal-linking’. Okay, sounds a little bit complicated, but it is really easy. 🙂 Plugin on … Read more

Shortlink directly to a media file?

It turns out this is easily solved by creating a file attachment.php and redirecting to the file itself. Create an attachment.php file in your WordPress theme folder Put this code in the file <?php wp_redirect(wp_get_attachment_url(), 301); ?> Upload it and there you go This link explains in full.