Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // in functions-admin.php
- // ==================
- // we can get all the post formats by get_post_format_slugs() function
- // it returns all formats including 'standard' format which we don't need
- // 'standard' is always on the top so its index is zero
- // so we can ignore it by a if condition if( $i != 0)
- function post_formats_callback() {
- $formats = get_post_format_slugs();
- $options = get_option( 'post_formats' );
- $output = '';
- $i = 0;
- foreach( $formats as $format ) {
- if( $i != 0) {
- $checked = ( @$options[$format] == $format ? 'checked' : '' );
- $output .= '<label><input type="checkbox" name="post_formats['.$format.']" '.$checked.' value="'.$format.'">' . $format . "</label><br>";
- }
- $i++;
- }
- echo $output;
- }
- // in theme-support.php
- // =================
- $options = get_option( 'post_formats' );
- if( ! empty( $options ) ){
- add_theme_support( 'post-formats', $options );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement