fix: ajout d'un plus d'info aux tags

This commit is contained in:
Kazhnuz 2020-12-31 11:53:45 +01:00
parent ab93b641de
commit 7690aa2bd3
2 changed files with 46 additions and 1 deletions

View file

@ -102,3 +102,43 @@ function mypost_social_sharing_buttons($content) {
}
};
add_filter( 'the_content', 'mypost_social_sharing_buttons');
add_action( 'post_tag_add_form_fields', 'kspace_add_term_fields' );
function kspace_add_term_fields( $taxonomy ) {
echo '<div class="form-field">
<label for="misha-text">Plus d\'Info</label>
<input type="text" name="plus-dinfo" id="plus-dinfo" />
<p>Une URL permettant d\'obtenir plus d\'information sur le tag.</p>
</div>';
}
add_action( 'post_tag_edit_form_fields', 'misha_edit_term_fields', 10, 2 );
function misha_edit_term_fields( $term, $taxonomy ) {
$value = get_term_meta( $term->term_id, 'plus-dinfo', true );
echo '<tr class="form-field">
<th>
<label for="misha-text">Plus d\'Info</label>
</th>
<td>
<input name="plus-dinfo" id="plus-dinfo" type="text" value="' . esc_attr( $value ) .'" />
<p class="description">Une URL permettant d\'obtenir plus d\'information sur le tag.</p>
</td>
</tr>';
}
add_action( 'created_post_tag', 'misha_save_term_fields' );
add_action( 'edited_post_tag', 'misha_save_term_fields' );
function misha_save_term_fields( $term_id ) {
update_term_meta(
$term_id,
'plus-dinfo',
sanitize_text_field( $_POST[ 'plus-dinfo' ] )
);
}

View file

@ -10,8 +10,13 @@
<div class="card card-info">
<div class="card-header"><i class="fa fa-fw fa-tag"></i> <?php echo single_cat_title(); ?></div>
<div class="card-body">
<p>Tout les éléments enregistré pour le tag <?php echo single_cat_title(); ?></p>
<?php echo tag_description();?>
<p><? echo '<a href="' . get_tag_link( $tag_id ) . 'feed/" title="RSS du tag" />Flux RSS</a> du tag'; ?></p>
<?php $infourl = get_term_meta(get_queried_object_id(), 'plus-dinfo', true);
if ($infourl != null) {
echo '<p class="align-center"><a href="' . $infourl . '" class="btn btn-readmore">Plus d\'info</a></p>';
}
?>
</div>
</div>