Limit categories, tag count on back-end?

Question

Before I re-invent the wheel. We are looking to limit the number of tags, or the number of categories that a specific blog article can be assigned to.

I currently do this on the front end, similar to:

<?php
$tags = wp_get_post_tags($post_id);
$html = '<div class="post_tags">';
$i=1;
foreach ( $tags as $tag ) {
    $tag_link = get_tag_link( $tag->term_id );  
    if($i<3)
    {
        $html .= "<li><a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
        $html .= "{$tag->name}</a><li>";
    }
    $i++;
}
$html .= '</div>';
echo $html;
?>

However, this has an issue, that if more tags are assigned, only the initial ones will show. Causing people to think there is an issue between their post and the displayed post.

Is it possible to just place a restriction on the back-end editior?

Note: I’m looking to do this for both tags and categories, but the implemenation is similar.

0
DDulla 8 months 2020-12-10T12:10:19-05:00 0 Answers 7 views 0

Leave an answer

Browse
Browse