Documentation

All the information you need in one place

How can I use shortlinks on my social messages?

As you probably know, you can use the {permalink} tag when creating social messages in Nelio Content. This tag is then replaced by the actual link of your post. But you can obviously create the message using the link directly. That is, instead of writing this:

Look at my newest post {permalink}

You can write this:

Look at my newest post https://short.link/post

But there’s a problem with this solution: you need to manually create all the social messages…

SOLUTION

Our plugin defines the following filter: nelio_content_post_permalink, with two arguments: $permalink and $post_ID. This means that you can easily create a custom function to make sure your posts are shared using a short link instead of the long one.

Here’s (roughly) how you’d do it:

1. Add a custom field in your post named, for example, nc_short_url:

Custom field for defining the proper short link of the post.
Custom field for defining the proper short link of the post.

2. Create a custom function such as this:

function nc_use_custom_short_link( $permalink, $post_id ) {
  $short_link = get_post_meta( $post_id, 'nc_short_url', true );
  return empty( $short_link ) ? $permalink : $short_link;
}//end nc_use_custom_short_link()
add_filter( 'nelio_content_post_permalink', 'nc_use_custom_short_link', 10, 2 );

As you can see, it’s a pretty simple function connected to the filter we mentioned before: it basically retrieves the post meta we just added and, if there’s one available, it returns it. Otherwise, it uses the default permalink.

If you don’t know where to place this function, follow these instructions.

Person writing a new WordPress post on a MacBook

Looking for popups?

We have the best plugin to create popups for WordPress in minutes.

Request Customized Enterprise Pricing

10
200000

With your express consent, we handle the information provided for the purpose of contacting you and until you ask us to delete it.

70% OF YOUR VISITORS DO EXACTLY WHAT
YOU JUST DID AND NEVER COME BACK!

KEEP THEM
ON YOUR SITE
LONGER WITH
NELIO POPUPS

Claim Your Discount Now

Image with a 10%-off coupon

WAIT! BEFORE YOU GO...

Get this awesome discount now!

No, I don't want to save money

Image with a 10%-off coupon

WAIT! BEFORE YOU GO...

Get this awesome discount now!

No, I don't want to save money

YOUR COOKIE SETTINGS


This site uses proprietary operational cookies that have a purely functional purpose and third-party cookies that help us understand how visitors interact with the site by collecting and presenting information anonymously. To get more information about these cookies and the processing of your personal data, check our Privacy & Cookie Policy. Do you accept these cookies and the processing of personal data involved?


If you don’t, you can reject non-operational cookies and continue browsing this site by clicking here.