• Hi

    I am trying to find the right place within the P2 code, to change the appearance of the post form.

    I have successfully changed the order that the tabs appear, to make “Blog Post” come before “Whats happening”

    But how do I change it so that the “Blog Post” form becomes the default when a page loads, so that most posts will have a title?

    Any ideas out there?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter kentonfox

    (@kentonfox)

    Im guessing something to do with how the page displays, so should I be looking at the css files.

    Sorry to ask dumb questions but I am learning … slowly

    Thread Starter kentonfox

    (@kentonfox)

    Move: || !isset($_GET['p'])
    From the postbox “status” line in post-forum.php to the post type you’d like to be the default.

    UPDATE: With the latest version of P2, this has changed.

    The function that controls the default post type is called p2_get_posting_type and it’s stored in the template-tags.php file. The default setup is:

    function p2_get_posting_type() {
    	$p = isset( $_GET['p'] ) ? $_GET['p'] : 'status';
    	return $p;
    }

    If you’d like to change the default post type — from status to post, for example — just change “status” to “post”. The other options are “quote” (for the Citation form) and “link” for the Hyperlink form.

    Cheers,
    Scott
    ___________________________________
    https://www.massivemouse.com

    Thanks, that’s most helpful.

    There’s just one small problem with this switch: the “Post Title” field doesn’t say “Post Title” in it (to tell people what its for) when you just visit the home page (or refresh). If you click in that field, then click somewhere else, the words suddenly appear. Any ideas on getting them to appear from the start?

    You need to modify the “value” attribute for the posttitle field in the #postbox-type-post in post-form.php. By default (in p2 version 1.1.8, it’s left blank — value=””). You need to change it to:

    value="<?php esc_attr_e( 'Add a title to your post', 'p2' ); ?>"

    The chunk of code you’re looking for in post-form.php is below. The empty “value” attribute is on the third line.

    <div id="postbox-type-post" class="post-input <?php if ( 'post' == p2_get_posting_type() ) echo ' selected'; ?>">
          <input type="text" name="posttitle" id="posttitle" tabindex="1" value=""
             onfocus="this.value=(this.value=='<?php echo esc_js( __( 'Add a title to your post', 'p2' ) ); ?>') ? '' : this.value;"
             onblur="this.value=(this.value=='') ? '<?php echo esc_js( __( 'Add a title to your post', 'p2' ) ); ?>' : this.value;" />
    </div>

    Change it to the following:

    <div id="postbox-type-post" class="post-input <?php if ( 'post' == p2_get_posting_type() ) echo ' selected'; ?>">
          <input type="text" name="posttitle" id="posttitle" tabindex="1"
             value="<?php esc_attr_e( 'Add a title to your post', 'p2' ); ?>"
             onfocus="this.value=(this.value=='<?php echo esc_js( __( 'Add a title to your post', 'p2' ) ); ?>') ? '' : this.value;"
             onblur="this.value=(this.value=='') ? '<?php echo esc_js( __( 'Add a title to your post', 'p2' ) ); ?>' : this.value;" />
    </div>

    NOTE: if you’re modifying template files like post-form.php, you should do so via a child theme. Otherwise, you’re changes will break if you update the theme in the future.

    Thanks for the info. It worked, except that it did something to the formatting of the main post text box. Its wider now, forcing it beneath the user’s avatar, there’s a citation field (like on the quotes option), and both the citation field and the tags field are both wider as well, and not as tall… did I do something wrong? I swear I just replaced that one part. And yes, in a child theme.

    EDIT: nevermind. I was pasting in the whole chunk of code and either its messed up in that block (but not just the one value you put first in your post) or I was removing too much or too little from the orignial when I was pasting it in. It works when I just paste in the one line in place of the value=””

    Thanks much, that’s perfect!

    @scottsemple

    Okay, now that I’ve (and lots of other people) used it a bit, there’s one main problem: unlike the default “Post Title” that appears there, this fix makes actual text appear there. With the default, it disappears when somebody clicks there, allowing them to type a new title without removing anything. However with this fix, the “Add a title to your post” is actual text in the field, which means it must be removed (backspace or delete), or it is included in the title. I had one user leave it on the end of their title, so it was “The Post Title They TypedAdd a title to your post”, while another user didn’t put in a title at all, so their title was “Add a title to your post”. I’m trying to make a site that’s as easy to use as possible, and if I have to choose, its easier/better to have no suggestion text in there, but use the first however many words of the post as the title, than to have multiple posts with the title “Add a title to your post.”

    I’m wondering if this is something that will be fixed with WP 3.1 and the P2 update that should follow? Then again, its not really a bug, if making a blog post the default, is not a part of the normal theme settings.

    EDIT: It must have something to do with the blog post not being the default built into the theme, because “Tag it” appears in the tag field just fine, but “Post Title” only after clicking in, then out of, the title field.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘P2 post options – change post tabs default’ is closed to new replies.