Skip Navigation

[Resolved] Click counting – most popular

This support ticket is created 4 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by katjaL 4 years, 8 months ago.

Assisted by: Nigel.

Author
Posts
#1554603

Hi, we are building a link site and we want to show for example most popular links. Would this kind of list based on click statistics be possible with Toolset or should I start with some other plugin – what would be your recommendation?

#1554739

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I'm not really sure what a link site is, but if it means creating posts where the content is an external link, and you want to track how often such links are clicked, I would say that Toolset doesn't include anything for such tracking built in, though you could no doubt augment a site made with Toolset with custom coding to fill in the gaps.

I would say if you can find a theme or plugin that is designed for this, then that would be the best option, and only resort to a custom solution including Toolset if you can't find anything that meets your needs.

#1557531

Hi Nigel, thank you. I think we have to rely on Toolset after all investigation because there might be customization needs for the links and Toolset post would be perfect for that.

I found a plugin Popular posts which can show also popular custom posts. This is perfect for click statistics when you open the post first and then you open the link. But in the beginning when we don't have any other content than the link to an external page, it seems like an extra step to be forced first open the post and then click the link. So I'm thinking if there was a way to redirect the visitor to the external page automatically. This way we would have both: the statistics of cutom post clicks and redirecting to the external page.

Does this sound sane? 🙂 I don't know though how to redirect the custom post page. It could be done with this kind of meta code <meta http-equiv = "refresh" content = "0; url = [types field='link' output='raw'][/types]" /> but this should be added to header of page, between head tags.

Would you have any better idea or advice how I could achieve that code to header? Perhaps I should do the custompost.php and add the code there, but what how would I add the [types field='link' output='raw'][/types]?

#1560037

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I think you should add a little PHP snippet (to Toolset > Settings > Custom Code) that uses the template_redirect hook to check what kind of page we are on and if it is a single post of the relevant post type then redirect to the URL from the custom field belonging to the post.

You'll need template_redirect (https://codex.wordpress.org/Plugin_API/Action_Reference/template_redirect) and is_singular (https://developer.wordpress.org/reference/functions/is_singular/) to check for the post type, and then wp_redirect() to perform the actual redirection (https://developer.wordpress.org/reference/functions/wp_redirect/), having retrieved the URL using get_post_meta (https://developer.wordpress.org/reference/functions/get_post_meta/).

#1560221

Thank you Nigel for this idea!