Support » Theme: P2 » Post format – default to 'blog post' and remove options.

  • Resolved gulliver

    (@gulliver)


    What’s the sensible way to have ‘blog post’ as the default format and remove the other options?

    P2

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi there. 🙂

    The first step is for you to create a child theme.

    We have guidance on how to do that, as well as some extra information around child themes, here:

    https://codex.wordpress.org/Child_Themes

    After you have created your child theme, copy the post-form.php file from the parent to your child theme’s directory.

    Next, locate the following code in the child theme’s file:

    <?php $post_format = isset( $_GET['p'] ) ? $_GET['p'] : 'status'; ?>

    The above is where the default post format is defined. You can change it from ‘status’ to ‘post’ like so:

    <?php $post_format = isset( $_GET['p'] ) ? $_GET['p'] : 'post'; ?>

    A little below that, you will find a listing of all the different post formats:

    <ul id="post-types">
    			<li><a id="status" class="post-format-button<?php if ( 'status' == $post_format ) : ?> selected<?php endif; ?>" href="<?php echo site_url( '?p=status' ); ?>" title="<?php esc_attr_e( 'Status Update', 'p2' ); ?>"><?php _e( 'Status Update', 'p2' ); ?></a></li>
    			<li><a id="post" class="post-format-button<?php if ( 'post' == $post_format || 'standard' == $post_format ) : ?> selected<?php endif; ?>" href="<?php echo site_url( '?p=post' ); ?>" title="<?php esc_attr_e( 'Blog Post', 'p2' ); ?>"><?php _e( 'Blog Post', 'p2' ); ?></a></li>
    			<li><a id="quote" class="post-format-button<?php if ( 'quote' == $post_format ) : ?> selected<?php endif; ?>" href="<?php echo site_url( '?p=quote' ); ?>" title="<?php esc_attr_e( 'Quote', 'p2' ); ?>"><?php _e( 'Quote', 'p2' ); ?></a></li>
    			<li><a id="link" class="post-format-button<?php if ( 'link' == $post_format ) : ?> selected<?php endif; ?>" href="<?php echo site_url( '?p=link' ); ?>" title="<?php esc_attr_e( 'Link', 'p2' ); ?>"><?php _e( 'Link', 'p2' ); ?></a></li>
    		</ul>

    Remove all of the formats apart from “post” in the above code:

    <ul id="post-types">
    			<li><a id="post" class="post-format-button<?php if ( 'post' == $post_format || 'standard' == $post_format ) : ?> selected<?php endif; ?>" href="<?php echo site_url( '?p=post' ); ?>" title="<?php esc_attr_e( 'Blog Post', 'p2' ); ?>"><?php _e( 'Blog Post', 'p2' ); ?></a></li>
    		</ul>

    Save your changes. “Post” will then be the default and only post format.

    Let me know how you get on with that or if you have any extra questions.

    Thanks, Siobhan.
    Excellent, comprehensive answer.

    When poring over code yesterday I’d missed the ‘change status to post’ bit in the ‘$post_format = isset’ line.

    Now sorted. 🙂

    You’re most welcome. 🙂 You know where to find us if extra questions come up, too.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Post format – default to 'blog post' and remove options.’ is closed to new replies.