0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.