May 4, 2011

Setting a limit to tags created by Autotag | CyberSEO Pro | Support Forum

Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_TopicIcon
Setting a limit to tags created by Autotag
Topic Rating: 5 Topic Rating: 5 Topic Rating: 5 Topic Rating: 5 Topic Rating: 5 Topic Rating: 5 (1 votes) 
December 26, 2022
5:27 pm
Avatar
MediFormatica
Member
Members
Forum Posts: 49
Member Since:
December 17, 2022
sp_UserOfflineSmall Offline

Hi,

I wonder if there is a way to limit the number of tags created by the "Auto Tag" feature.

I usually have 3-4 defined "Post tags" and have the "Tags from category names" feature enabled (lovely feature) but I also have the "Auto tags" feature on. Having those setup helps with the "Related Articles" on my site and visibility of social media.

I recently started Auto posting to Instagram and the posts started being rejected because they exceed the 30 tags limit.  I didn't have this issue on Facebook or LinkedIn. When posting to Twitter anything beyond 280 characters gets cut anyway.

Login to see the quote

Maybe I could add the manual tags followed by the category tags and start adding auto tags until they reach the limit of 30, then stop the autotag function. 

Otherwise, I would just put a static number for the maximum number of tags to be produced by Autotag (e.g. 15), in which case ideally those would the tags that appear the most on the post.

Another idea would be to say Autotag shouldn't add a tag if it didn't appear an X number of times in the post. That may be best as it would be based on a sound logic rather than just a number. Of course in a very long post this can pick up too many tags.

December 26, 2022
7:13 pm
Avatar
CyberSEO
Admin
Forum Posts: 3909
Member Since:
July 2, 2009
sp_UserOfflineSmall Offline

Login to see the quote

Course the simplest and more universal solution will be to limit the maximum number of tags, but how the plugin will know which tags are the most important ones?

Login to see the quote

This will require some additional resources. PHP is interpreter. It's not a compiled executable, so it's better to avoid such practices.

Login to see the quote

The same as above. Also who knows may be the most important tag will appear just once...

I see only the way to just limit the maximum number of autotags per post.

December 27, 2022
11:11 pm
Avatar
MediFormatica
Member
Members
Forum Posts: 49
Member Since:
December 17, 2022
sp_UserOfflineSmall Offline

Thanks, I agree with your comments, which made me think about the real issue here; its posting to Instagram. So I don't want to limit  the tags for the other social media posts.

To get around this issue I've created a new custom field and will be filling it with 29 tags on publishing the post. I can do some minor filtering, like excluding tags that are less than 4 characters long, but I couldn't find a way to sort the tags by the number of times they appear in a post. So basically it is just a count with the first 29 tags (sorted alphabetically) being sent to Instagram.

Login to see the code

December 27, 2022
11:53 pm
Avatar
CyberSEO
Admin
Forum Posts: 3909
Member Since:
July 2, 2009
sp_UserOfflineSmall Offline

Login to see the code

It will contain an array of tag names sorted from the most repeated to the least repeated one. After that do your foreach ($tag_names as $tag_name).

December 28, 2022
8:13 am
Avatar
MediFormatica
Member
Members
Forum Posts: 49
Member Since:
December 17, 2022
sp_UserOfflineSmall Offline

You're a STAR...

Works well now, I'm actually thinking I might just use it for all social posts, not just Instagram wink.

Here's the final code for anyone else who would need it in the future. I've also filtered out tags that have 0 occurrences (probably coming from my manual tags or imported categories) and stripped spaces + lowercase the final hashtags.

Login to see the code

December 28, 2022
8:38 am
Avatar
CyberSEO
Admin
Forum Posts: 3909
Member Since:
July 2, 2009
sp_UserOfflineSmall Offline

Good to know it worked for you. Note this line in my code above:

Login to see the code

Some may think it's a redundant line because that's can be done right in the foreach loop, which makes the code shorter. And that's correct, the code will be shorter... but much slower, because a static (the one which doesn't get changed) variable $post->post_content will be lowercased in every iteration.

The modern compilers like those used to process C/С++ source files will automatically fix it for you. They are called optimizing compilers because they optimize your code in the process of compilation. They make note that there is no need to call strtolower() every iteration, and just make all the necessary changes in the generated code, and that takes a time.

PHP is not a compiler and is has no idea what code optimization is, so this task lies entirely on the programmer.

Forum Timezone: Europe/Amsterdam

Most Users Ever Online: 541

Currently Online:
20 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

ninja321: 84

s.baryshev.aoasp: 68

Freedom: 61

Pandermos: 54

MediFormatica: 49

B8europe: 48

Member Stats:

Guest Posters: 337

Members: 2816

Moderators: 0

Admins: 1

Forum Stats:

Groups: 1

Forums: 5

Topics: 1625

Posts: 8271

Newest Members:

jeremyboucher, lthompson2709, MAC, duty3canada, backlinkmorocco, dmitrypehovskiwork

Administrators: CyberSEO: 3909