4
votes
wp_get_canonical_url showing first url of the post for custom page
This is because wp_get_canonical_url can only be used on posts, and cannot be used for tags authors archives etc.
Returns the canonical URL for a post.
https://developer.wordpress.org/reference/...
1
vote
Accepted
Code to check how many posts a tag has?
You can use the found_posts property of the WP_Query class, to get the total number of posts in the queried tag (post_tag taxonomy), provided that the no_found_rows argument is not true:
global $...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
tags × 1307categories × 229
custom-post-types × 131
posts × 129
custom-taxonomy × 112
taxonomy × 91
wp-query × 79
php × 78
functions × 70
loop × 58
search × 58
terms × 44
archives × 41
filters × 39
query × 37
plugins × 35
pages × 34
customization × 32
permalinks × 29
conditional-tags × 27
woocommerce-offtopic × 26
theme-development × 25
html × 25
templates × 23
custom-field × 21