Redirect URL to Post Archives - Chatty Mango https://chattymango.com/category/updates/redirect-url-to-post/ WordPress Plugins Thu, 09 Sep 2021 12:42:57 +0000 en-US hourly 1 https://chattymango.com/wp-content/uploads/2020/06/cropped-logo_Chatty_Mango_favicon-32x32.png Redirect URL to Post Archives - Chatty Mango https://chattymango.com/category/updates/redirect-url-to-post/ 32 32 135434061 Redirect URL to Post, Versions 0.20.0 and 0.21.0: New Parameters https://chattymango.com/redirect-url-to-post-versions-0-20-0-and-0-21-0-new-parameters/?pk_campaign=rss&pk_kwd=redirect-url-to-post-versions-0-20-0-and-0-21-0-new-parameters Thu, 09 Sep 2021 12:42:55 +0000 https://chattymango.com/?p=9437 Continue reading Redirect URL to Post, Versions 0.20.0 and 0.21.0: New Parameters]]> These two releases of the Redirect URL to Post WordPress plugin that takes your visitors directly to any random or other post adds some new filter parameters:

author__in, author__not_in, category__and, category__in, category__not_in, post__in, post__not_in, post_name__in, post_parent, post_parent__in, post_parent__not_in, tag__and, tag__in, tag__not_in, tag_slug__and, tag_slug__in

You will find them useful to narrow down the group of posts that should serve as basic set that we should pick the final destination from. Where ever you need to submit an array (see link below), you write the values as comma-separated list: tag__in=12,13,43

The parameter post_type is not new but now it understands also multiple post types, which you submit as comma-separated values: post_type=post,product.

Since these parameters work through the basic WordPress API, you find more information in the WordPress documentation.

]]>
9437
Redirect URL to Post, Version 0.19.0: Custom Pass-Through Parameters https://chattymango.com/redirect-url-to-post-version-0-19-0-custom-pass-through-parameters/?pk_campaign=rss&pk_kwd=redirect-url-to-post-version-0-19-0-custom-pass-through-parameters Wed, 17 Feb 2021 14:07:57 +0000 https://chattymango.com/?p=9064 The latest release of the Redirect URL to Post WordPress plugin comes with a small new feature: Now you can define your own URL parameters that will simply be passed through to the final URL.

Until now only some selected tracking parameters were allowed. These parameters help you track redirects in web statistics.

Now, if you need any custom parameters, you can whitelist them in the wp-config.php file. Simply define a constant with a comma-separated list of your URL parameter keys. If it is only one key, you naturally don’t use any commas.

Example

Add into wp-config.php:

define( 'CHATTY_MANGO_RUTP_PASS_THROUGH', 'go,do' );

This would pass through any parameters like …&go=there&do=that.

Background

In case you are wondering why we’re not saving ourselves the trouble of whitelisting URL parameters in the first place: It’s for the extra peace of mind. Remember that anyone can modify the URL and then run it on your site. A reserved parameter could trigger something on the post or page where the redirect ends. And all that would be cloaked by a redirect.

While I’m not aware of any actual case where this could happen, I prefer to be a bit more restrictive rather than having to deal with the damage if someone discovers a loophole. The site owner should always be in control.

Photo by Christoph Amthor

]]>
9064
Redirect URL to Post, Version 0.18.0: Time Lock for Redirects https://chattymango.com/redirect-url-to-post-version-0-18-0-time-lock-for-redirects/?pk_campaign=rss&pk_kwd=redirect-url-to-post-version-0-18-0-time-lock-for-redirects Sun, 11 Oct 2020 12:52:09 +0000 https://chattymango.com/?p=8491 This version of the Redirect URL to Post WordPress plugin adds two new URL parameters: a “time lock” and an option for the scope of cookies.

Stay a while with one post

The parameter lock lets you “lock”((Of course, it is possible to go to another post. We mean that the redirect_to link will redirect to the same post.)) a visitor to one post for a specified time. This way you can make sure that each visitor keeps seeing the same post until the time has expired. Use the parameter with a number in seconds.

Example:

www.example.com/?redirect_to=random&lock=86400

This feature works only in the same browser and if the visitor accepts and keeps cookies.

Possible applications:

  • Show a random post of the day.
  • Offer random posts through a link or button but make sure visitors can reload a post through the same link or button.

Please note that we still need to query the list of posts and check if the locked post is among them. If you want to reduce the database load, use the parameter cache.

Site-global cookies

Cookies (for each_once and lock) have now by default a domain-wide validity. That means that the posts a visitor has seen and the above-mentioned lock deliver the same result no matter which page the visitor is on.

You can switch to separate cookies per directory with the parameter directory_cookie (no value required). That is particularly useful if you use lock when redirecting to the previous or next post.

The complete changelog is available here.

Photo by Christoph Amthor

]]>
8491
Redirect URL to Post, Version 0.17.0: Use Only Specified Posts https://chattymango.com/redirect-url-to-post-version-0-17-0-use-only-specified-posts/?pk_campaign=rss&pk_kwd=redirect-url-to-post-version-0-17-0-use-only-specified-posts Sat, 26 Sep 2020 16:11:02 +0000 https://chattymango.com/?p=8440 The latest version of the Redirect URL to Post WordPress plugin adds a new parameter. Using include with a comma-separated list of post IDs, you can directly specify which posts you need. That way you can, for example, direct to a random item among a list of posts.

Example:

http://www.example.com?redirect_to=random&include=23,67,348

photo by Christoph Amthor

]]>
8440
Redirect URL to Post, Version 0.16.0: Filter by Custom Taxonomies https://chattymango.com/redirect-url-to-post-version-0-16-0-filter-by-custom-taxonomies/?pk_campaign=rss&pk_kwd=redirect-url-to-post-version-0-16-0-filter-by-custom-taxonomies Mon, 03 Aug 2020 13:33:38 +0000 https://chattymango.com/?p=7487

The latest version of the Redirect URL to Post WordPress plugin enables you to filter posts by custom taxonomies.

Three parameters are available: custom_taxonomy_slug, custom_taxonomy_field and custom_taxonomy_term

  • custom_taxonomy_slug is the slug of the custom taxonomy, such as product_tag or product_cat
  • custom_taxonomy_field tells WordPress how to identify the tag or category. Allowed values are “term_id”, “name”, “slug” and “term_taxonomy_id”. The default is “slug”.
  • custom_taxonomy_term is the tag or category. Depending on custom_taxonomy_field you specify them as slugs, IDs or others. You can also use a comma-separated list of multiple terms.

Example:

http://www.example.com?redirect_to=random&custom_taxonomy_slug=product_cat&custom_taxonomy_field=slug&custom_taxonomy_term=shelf-warmers,grannys-favorites

Photo by Christoph Amthor

]]>
7487
Redirect URL to Post, Version 0.15.0: Each Post Only Once in Random Order https://chattymango.com/redirect-url-to-post-version-0-15-0-each-post-only-once-in-random-order/?pk_campaign=rss&pk_kwd=redirect-url-to-post-version-0-15-0-each-post-only-once-in-random-order Wed, 08 Apr 2020 08:41:31 +0000 https://chattymango.com/?p=7171

The latest release of the Redirect URL to Post WordPress plugin adds another parameter: each_once

With each_once you can prevent that visitors see the same post twice in a series of random posts. Use each_once=rewind to start over again after all posts are done. Use each_once= with a target post/page ID if you want to send your visitors to a post or page after all posts are done.

Example:

www.example.com/?redirect_to=random&each_once=rewind

This feature works only if visitors have cookies enabled.

Hint: If you add the parameter &rutpdebug, you will see a warning if the post IDs wouldn’t fit into a cookie.

Photo by Christoph Amthor

]]>
7171
Redirect URL to Post, Version 0.14.0: Debugging Parameter https://chattymango.com/redirect-url-to-post-version-0-14-0-debugging-parameter/?pk_campaign=rss&pk_kwd=redirect-url-to-post-version-0-14-0-debugging-parameter Tue, 11 Feb 2020 14:00:25 +0000 https://chattymango.com/?p=7068 The latest release of the free WordPress plugin Redirect URL to Post adds a new parameter: rutdebug. When you apply it, the plugin will show you some information about what is going on when trying to find a matching post.

If you use the value rutdebug=2, you will also see relevant parameters of the database query.

Since this information is accessible from the frontend, we expose no internal or critical data. Everything visible here can be inferred from the URL parameters. The resulting link is exactly what we would normally redirect to.

]]>
7068
Redirect URL to Post, Version 0.13.0: Go to Previous or Next Post https://chattymango.com/redirect-url-to-post-version-0-13-0-go-to-previous-or-next-post/?pk_campaign=rss&pk_kwd=redirect-url-to-post-version-0-13-0-go-to-previous-or-next-post Sat, 18 Jan 2020 10:52:48 +0000 https://chattymango.com/?p=6873

The latest release of the WordPress plugin Redirect URL to Post comes with another useful enhancement: Using redirect_to=prev and redirect_to=next you can send your website visitors to the previous or next post.

The post order is determined by publishing dates. Unlike when using hard-coded links to previous and next posts, we identify the target post only at the time when a visitor enters the link. We also match the post type of the current post. Yes, it even works with pages, although there might not be many cases where pages have a chronological order.

These new parameters have not been tested in combination with others, except “offset”, which lets you go to the 1st, 2nd, … after the next or previous post. You definitely cannot use with them “post_type”, “before” and “after”.

No Jumping the Queue

Since we need to know the ID of the current post in order to find out where to go, the plugin has to wait a bit longer than usual until it can spring into action. I haven’t seen it during testing, but theoretically it might happen that another plugin has already sent some output to the browser and you will see an error message: “Headers already sent”.

Unfortunately, there is not much we can do about those hasty plugins. We particularly cannot jump the queue and run earlier, since we don’t know where we’re heading before we know the post ID.

For all other redirect_to options we still hook earlier into the WordPress workflow. No change here.

Available Now

The new version is available on your admin backend. Or go to the WordPress plugin repository where you will find it waiting just for you.

Photo by Christoph Amthor

]]>
6873
How to Display a Random Post in WordPress https://chattymango.com/how-to-display-a-random-post-in-wordpress/?pk_campaign=rss&pk_kwd=how-to-display-a-random-post-in-wordpress Thu, 16 Jan 2020 08:33:43 +0000 https://chattymango.com/?p=6859

WordPress offers many ways how to display posts in random order((You can use for example a shortcode.)). Sometimes, however, you want to show one – and only one – random post.

There are several reasons why you may want to show a random post:

  • revive old content
  • give an equal chance to all authors
  • increase on-site engagement and visitor retention for a better SEO score

All you need is the free plugin Redirect URL to Post from the official WordPress repository. It offers caching of database results (default is 60 seconds) and many other advanced features that I will present below.

After you installed and activated the plugin, you simply add ?redirect_to=random to the end of your site’s URL. For example:

https://www.my-wordpress-blog.com/?redirect_to=random

Once you press enter, the plugin will automatically pick a random post and insert the correct URL.

This URL can be used in any menu or button. You can even send it to your newsletter subscribers.

Advanced Options

Higher Probability For Recent Posts

The feature I like most is the option to use a different probability for older and newer posts. Recent posts are naturally more interesting and relevant, so you may want to show them more often.

You will need two parameters: count to determine the amount of new posts that receive a different weight and bias to determine the percentage that these posts should appear.

Here is an example:

https://www.my-wordpress-blog.com/?redirect_to=random&count=10&bias=80

In this example the first 10 posts are picked with a probability of 80% and the rest with a probability of 20%. You can see in the example that only the first parameter is added with a “?” while all the others use “&”.

Power users may want to check out the parameter offset that lets them skip the very latest posts.

Use Only a Subset of Posts

Sometimes you don’t want to consider all posts but only a subset. Fortunately, the plugin lets you filter by author, post type (e.g. products), time frame or others.

The following link lets you redirect to a random post that is older than 1 month but not older than 6 months. That way you can revive posts that are neither brand-new nor totally outdated. Relative time formats give you a powerful tool to determine a point in time.

https://www.my-wordpress-blog.com/?redirect_to=random&before=1%20month%20ago&after=6%20month%20ago

Note that “month” is used in singular and that spaces are encoded as “%20”. Without spaces the parameters will be more readable.

https://www.my-wordpress-blog.com/?redirect_to=random&before=1 month ago&after=6 month ago

Track Random Redirects With Analytics

If you want to track redirected visitors with Google Analytics, you can add a tracking parameter that will be carried over to the final URL.

https://www.my-wordpress-blog.com/?redirect_to=random&utm_campaign=random_link

Supported tracking parameters are utm_source, utm_campaign, utm_medium, utm_term, utm_content, pk_campaign, pk_kwd, pk_source, pk_medium and pk_content

Summary

The plugin Redirect URL to Post comes with a handy set of options to send your visitors to a random post.

You can find more details and other possibilities of redirects in the documentation.

Photo by Christoph Amthor

]]>
6859
Redirect URL to Post, Version 0.12.0: Filter by Comment Count https://chattymango.com/redirect-url-to-post-version-0-12-0-filter-by-comment-count/?pk_campaign=rss&pk_kwd=redirect-url-to-post-version-0-12-0-filter-by-comment-count Wed, 05 Jun 2019 16:15:54 +0000 https://chattymango.com/?p=6637 The latest release of the free WordPress plugin Redirect URL to Post adds three new parameters to filter posts by comments:

comment_count, comment_count_min, comment_count_max

Values are integers. comment_count also accepts negative values (even-0), which means “not x”.

  • Have no comments: comment_count=0
  • Have comments: comment_count_min=1 or comment_count=-0
  • Have <= x comments: comment_count_max=x
  • Have >= x comments: comment_count_min=x

If you need < and > instead of <= and >=, you simply use x-1 or x+1.

]]>
6637