5:27 pm
December 17, 2022
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.
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.
11:11 pm
December 17, 2022
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
8:13 am
December 17, 2022
You're a STAR...
Works well now, I'm actually thinking I might just use it for all social posts, not just Instagram .
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
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.
Most Users Ever Online: 541
Currently Online:
9 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: 2853
Moderators: 0
Admins: 1
Forum Stats:
Groups: 1
Forums: 5
Topics: 1640
Posts: 8352
Newest Members:
wanmarkets, torontomark48, info.ckmedianetwork, contact.mybeautystar, samuelbodde, john.prushAdministrators: CyberSEO: 3947