Support » Fixing WordPress » New Page not blank

  • Hi. It does not sound professional to ask my user to copy and paste the html code of 2 tables into the html source of each new page.

    Is not there a more elegant way of doing that? Plugin ? Child Theme?

Viewing 15 replies - 1 through 15 (of 18 total)
  • Your question is kind of vague. Could you specify exactly what the issue is? Also, if possible, drop of a URL?

    I have a user who almost in every single new page wants to have the same two tables that he fills in with data about the article on that page.

    My easy way of doing this is to copy-paste the required html code to the html source of the new page box editor.

    But it does not sound professional to ask a user to copy-paste the html code of those two tables to every new page.

    still not clear ?

    Put the code below into your functions.php file to have default text appear when you make a new post/page.

    <?php
    
    add_filter( 'default_content', 'my_editor_content' );
    
    function my_editor_content( $content ) {
    
    	$content = "This is some custom content I'm adding to the post editor because I hate re-typing it.";
    
    	return $content;
    }
    
    ?>

    Let me explain the code above. The part that says:

    $content = "This is some custom content I'm adding to the post editor because I hate re-typing it.";

    is where you need to put in your content. You can put in html. Just add it inside the quotes to have the tables appear in every post/page. If you put in HTML, you have to make sure that you put a backslash before all of the single quotes and/or apostrophes. For example:

    $content = "<p>It\'s great to work on WordPress!</p>";

    Note the backslash before the apostrophe in “It’s”.
    Here is a plugin that will set the default text for you:
    http://wordpress.org/extend/plugins/default-post-content/

    I hope this helps!

    thank you munny. I sincerely appreciate your help.
    The plug-in “Default Post Content” does not serve my goal as my user is using Pages not articles.

    but I will try functions.php

    Let me see what I can do…

    munny, thank you for your help

    At which position in functions.php should I insert this code ?

    <?php

    add_filter( ‘default_content’, ‘my_editor_content’ );

    function my_editor_content( $content ) {

    $content = “This is some custom content I’m adding to the post editor because I hate re-typing it.”;

    return $content;
    }

    ?>

    Here are two solutions for pages:
    1. When you create the page, paste the table in so that your user has the table there for him/her (if the user creates the pages, move to the next option).
    2. Copy the code from page.php into a text editor like Notebook or TextEdit (plaintext editor), edit this page.php in your choice of editor like so:
    Add these five lines to the top:

    <?php
    /*
    Template Name: <em>[your page name here]</em>
    */
    ?>

    Change [your page…] to a template name like “Table” (without the quotes)
    THEN:
    Change this:
    <?php get_template_part( 'content', 'page' ); ?>
    To this:

    <?php get_template_part( 'content', 'page' ); ?>
    <?php include(“default_page_values.html”); ?>

    Once you have done this, upload it to your FTP client under wp-content>themes>[your theme name]. Make another file that MUST be called default_page_values.html in your editor. Put your default HTML/text in it. Upload to the same location where you uploaded the template.
    Now, whenever you make a new page, just choose the template that has your pre chosen name to have the default text there.
    (Sorry for the wait)

    <?php
    
    add_filter( 'default_content', 'my_editor_content' );
    
    function my_editor_content( $content ) {
    
    $content = "This is some custom content I'm adding to the post editor because I hate re-typing it.";
    
    return $content;
    }
    
    ?>

    Put this anywhere. It, however, may not work. Try out my other post. It might work. If my other post does not work out, you will have to give me some time to research and see if I can find you some answers. In the mean time, some WordPress geniuses might answer your question!

    thank you.

    I tried this method:

    <?php
    add_filter( 'default_content', 'my_editor_content' );
    function my_editor_content( $content )

    it did not work and when I try to create a new page, I get a totally blank page in my browser. (IE9 on Win7)

    I tried the other method:

    <?php get_template_part( 'content', 'page' ); ?>
    <?php include(“default_page_values.html”); ?>

    But that also did not give the expected outcome. (the editing box of a new page remained blank when the right template is chosen in the drop-down menu to the right)

    Disregard this.

    Here is the real deal. This will work. I am sure.

    function dmg_default_text_in_editor( $content, $post ) {
      if ( 'page' == $post->post_type ) $content .= 'Default page content.';
      return $content;
    }
    
    add_filter( 'default_content', 'dmg_default_text_in_editor', 10, 2 );

    Replace ‘Default page content’ with your own content.
    ——
    Here is another code if you want to do this for both posts and pages:

    function dmg_default_text_in_editor( $content, $post ) {
      if ( 'page' == $post->post_type ) $content .= 'Default page content.';
      if ( 'post' == $post->post_type ) $content .= 'Default post content.';
      return $content;
    }
    
    add_filter( 'default_content', 'dmg_default_text_in_editor', 10, 2 );

    Replace the ‘Default…’ with your own content. Sorry about the other posts. Sometimes things just do not work… Anyway, hopefully this will be successful.

    thank you.
    I’d highly appreciate it if you kindly give me clear instructions such as: go to file.php, edit abc, replace with xyz.

    I am not sure what to do with the code you posted.

    Sorry about that! Just put it in your functions.php

    Thank you a MILLION!
    That worked.

    But how can I protect my changes against future theme updates?

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘New Page not blank’ is closed to new replies.