1 / 10

Advanced Layout Templates in WordPress Content Editor

This article will help you to understand how to manage multi-column content layouts within the comfort of the WYSIWIG editor.

Download Presentation

Advanced Layout Templates in WordPress Content Editor

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Advanced Layout Templates in WordPress Content Editor We all know even with a little knowledge of HTML we can update or maintained any WordPress powered website. Like add or remove pages, content, images, products, blogs etc. where as a Tiny MCE rich-text editor can give any skill level or tools web editors need to style and publish their post. But creating something beyond a single column text with some floated images requires at least a basic knowledge of HTML. This article will help you to understand how to manage multi- column content layouts within the comfort of the WYSIWIG editor .

  2. Creating a Custom Layout Here we are going to insert a few HTML elements into the editing window and style them. WordPress’ default_content filter allows us to insert set content into any post THE BACK END By adding the following to functions.php, each new post we create will come pre-stocked with two divs, classed content-col- main and content-col-side, respectively <?php add_filter('default_content','custom_editor_content'); functioncustom_editor_content($content){ $content= ' <div class="content-col-main"> This is your main page content &nbsp; </div> <div class="content-col-side"> This is your sidebar content &nbsp; </div>

  3. '; return$content; } ?> Now give some style <?php add_editor_style('editor-style.css'); ?> Create a style sheet named editor-style.css, and place it in the theme folder body{ background: #f5f5f5; } .content-col-main { float:left; width:66%; padding:1%; border: 1px dotted #ccc; background: #fff; }

  4. .content-col-side { float:right; width:29%; padding:1%; border: 1px dotted #ccc; background: #fff; } img{/* Makes sure your images stay within their columns */ max-width: 100%; width: auto; height: auto; } Now, when you create a new post, you will see two columns that you can type or paste your content into:

  5. Now you have it - a simple multi-column template in your content editor.

  6. THE FRONT END You can also use this technique to create objects to target later with JavaScript.

  7. To create a different default layout template to each of your post types: <?php add_filter('default_content','custom_editor_content'); functioncustom_editor_content($content){ global$current_screen; if($current_screen->post_type=='page'){ $content= '

  8. // TEMPLATE FOR YOUR PAGES '; } elseif($current_screen->post_type=='POSTTYPE'){ $content= ' // TEMPLATE FOR YOUR CUSTOM POST TYPE '; } else{ $content= ' // TEMPLATE FOR EVERYTHING ELSE '; } return$content; } ?> But if you’d like to use a different style sheet entirely for each post type,you can do so with this snippet from WPStorm: <?php functioncustom_editor_style(){

  9. global$current_screen; switch($current_screen->post_type){ case'post': add_editor_style('editor-style-post.css'); break; case'page': add_editor_style('editor-style-page.css'); break; case'[POSTTYPE]': add_editor_style('editor-style-[POSTTYPE].css'); break; } } add_action('admin_head','custom_editor_style'); ?> The above explanation is based on the assumption that you already know the layout that your client wants to give their content as the layout structures cannot be easily edited by clients. Hope this article will help you to create an advance layout template in WordPress and also improve your wordPress website development workflow.

  10. iMediadesigns provide cost effective web design and development solutions and offers custom website design services in Toronto.

More Related