Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter chanpory

    (@chanpory)

    Okay, I figured out some hacks to get Tag description working. They’re core hacks for now. I assume it could be turned into a plug-in but I have little experience in that. For now, here’s what you can do to enable Tag Descriptions.

    In wp-admin/edit-tag-form.php, add the following code right before the </table> tag:

    <tr class="form-field">
    			<th scope="row" valign="top"><label for="description"><?php _e('Description') ?></label></th>
    			<td><textarea name="description" id="tag_description" rows="5" cols="50" style="width: 97%;"><?php echo wp_specialchars($tag->description); ?></textarea><br />
                <?php _e('The description is snot prominent by default, however some themes may show it.'); ?></td>
    		</tr>

    This will create a description field in the edit tags form in WordPress admin.

    Next, in wp-includes/general-template.php, add the the following function:

    function single_tag_description($prefix = '', $display = true ) {
    	if ( !is_tag() )
    		return;
    
    	$tag_id = intval( get_query_var('tag_id') );
    
    	if ( !empty($tag_id) ) {
    		$my_tag = &get_term($tag_id, 'post_tag', OBJECT, 'display');
    		if ( is_wp_error( $my_tag ) )
    			return false;
    		$my_tag_description = apply_filters('single_tag_description', $my_tag->description);
    		if ( !empty($my_tag_description) ) {
    			if ( $display )
    				echo $prefix . $my_tag_description;
    			else
    				return $my_tag_description;
    		}
    	}
    }

    This will allow you to display the Tag’s description text on a Tag archive page. Just put in this code into your theme:

    <?php single_tag_description(); ?>

    Hope that helps anyone who wondered why Tag description text was omitted

    Thread Starter chanpory

    (@chanpory)

    Yeah, quite weird. It’d be nice to have the feature.

    mfields, it’d actually be useful to change the category ID number, because of the way multiple categories work with posts.

    From my understanding, if a post is assigned more than one category, WordPress will assign the category with the lowest ID number as the primary category. Currently, there is no way to assign a primary category to a post, which is quite frustration.

    Thread Starter chanpory

    (@chanpory)

    Thanks so much Kafkaesqui!!!!

    The way to do it is to use the get_the_author tag.

    <?php $author = get_the_author(); ?>

    https://codex.www.ads-software.com/Template_Tags/get_the_author

Viewing 5 replies - 1 through 5 (of 5 total)