Load all category posts in one template with format ‘posts-of-category-CatSlug’

To load all the category posts in same template file add the below hook to functions.php file :

function load_cat_parent_template(){
global $post;
$catsArr = array(‘posizioni-aperte’);
$cat = get_the_category($post->ID);
$template = TEMPLATEPATH . “/posts-of-category-“.$cat[0]->slug.”.php”;
load_template( dirname( __FILE__ ) . “/child-of-category-“.$cat[0]->slug.”.php” );


Add page parent class to subpage parent page in nav menu

To add class current to current sub page parent in top nav menu or any other nav menu add the below hook to functions.php file:

function add_class_to_wp_nav_menu($classes){
global $wp_query;
$post = $wp_query->post;
$pageMenuID = $post->post_parent;
$menu_items = wp_get_nav_menu_items(‘top menu’);
foreach($menu_items as $page) {
if( $page->post_parent == $pageMenuID){
$currentMenuItem = $page->ID;
$parentArr = get_page_by_path(‘lavora-con-noi’);
if( $page->post_parent == $parentArr->ID){
$currentMenuItem = $page->ID;

// add the current page class to a specific menu item (replace ###).
if (in_array(‘menu-item-‘.$currentMenuItem, $classes)){
$classes[] = ‘current-menu-item current_page_parent’;
return $classes;

Stop WordPress from adding p tags and removing line break

The hook to keep line break and  convert newline characters to BR tags “<br/>” also keep the redundant BR tags like “<br/> <br/>”  in editor of wordpress, just add the below hook in functions.php :


function tinymce_config( $init ) {
// Don’t remove line breaks
$init[‘remove_linebreaks’] = false;
// Convert newline characters to BR tags
$init[‘convert_newlines_to_brs’] = true;
// Do not remove redundant BR tags
$init[‘remove_redundant_brs’] = false;
// Pass $init back to WordPress
return $init;
add_filter(‘tiny_mce_before_init’, ‘tinymce_config’);


Reorder Menu Item In WordPress Admin

You can reorder the Admin menu items in wordpress in 2 cases as following:

1- Current Menu Items:

You can reorder current menu items by Adding the following function to wp-content/themes/Your Theam Folder/functions.php:

   function custom_menu_order($menu_ord) {
       if (!$menu_ord) return true;
       return array(
        'index.php', // this represents the dashboard link
        'edit.php', //the posts tab
        'upload.php', // the media manager
        'edit.php?post_type=page', //the posts tab
   add_filter('custom_menu_order', 'custom_menu_order');
   add_filter('menu_order', 'custom_menu_order');

2- Custome Menu Items Created by Hooks (Add New Menu Item In WordPress Admin):

Add New Menu Item In WordPress Admin

You can add Menu Items to admin in wordpress without use a plugin by using Hooks as following:

1- The function you will use For Menu Item is “add_menu_page();”


add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );


For more details about Function param visit: Add Menu Wordpress Codex

2-  The function you will use For SubMenu Item is “add_submenu_page();”


add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function );


For more details about Function param visit: Add Submenu Wordpress Codex


*   Example for menu & submenu Items:

function my_menu_pages(){
add_menu_page(‘My Page Title’, ‘Homepage’, ‘manage_options’, ‘cat9’, ‘my_menu_output’,’/wp-admin/images/generic.png’,’4.1′);
      add_submenu_page(‘cat9’, ‘Homepage Slides’, ‘Homepage Slides’, ‘manage_options’, ‘edit.php?cat=20’);

add_action(‘admin_menu’, ‘my_menu_pages’);


* End


Add/Edit/Delete Admin menu tap in WordPress

You want to Add,Edit or Delete tap from Administrator menu in wordpress so you need the following plugin to have full control on your admin menu

Below some screenshots for the module

click below link to download file and remember to change file extension From (.doc) to (.zip) and upload the plugin


Create A Form In WordPress

This registration form would be where people could submit their personal information and copy of payment receipt to register for the competition. Here’s how cformsII features helped us to complete the task.

Downloading And Installing

Let’s start with the installation process. You can’t use the WordPress built-in plugin search to find cformsII. You have to go to their site to download the plugin.

creating a registration form

Then go to your WordPress blog and click “Add New” sub menu under “Plugins“.

creating a registration form

In the “Install Plugins” page, click the “Upload” link, click “Choose File” and browse for the downloaded plugin, and finally click “Install Now“.

create a registration form

You’ll got new new menu on the site.

creating a registration form

Building New Forms

This plugin comes with one basic form which can be adjusted easily to fit users’ need. To begin, you can easily change the name of the form.

wordpress registration form

Then you can edit the name and type of each field of the form. Adding new lines is also as simple as telling cformsII how many and where to put the new fields. Just make sure that you’ve already planned about how many fields that you need in your form and the function of each one.

wordpress registration form

There’s the “Admin Actions” pane on the right side of the screen. You can use it to add new forms or duplicate the current form. But the most important function of this pane is the “Update Settings” button. Don’t forget to click this button every time you made changes to your form to save the changes.

wordpress registration form

The easiest way to modify each form field is to use the “Input Field Settings“. You can open the window by clicking the box in the middle of every field. (While the other boxes after the “Type” options are the delete button)

03b Form Settings - Fields B-1.png

For example, you want to create checkbox with multiple choices, you can choose “Multiple Checkbox” from the drop down “Type” options, click the “Input Field Settings” button, then define each checkbox choices.


By combining text inputs and checkboxes, we can create almost any kind of form. And one of the field types is “File Upload Box” which allows people to upload small file such as copy of payment receipt.

03j File Upload.png

You can also create as many forms as you need using “Add new form” or “Duplicate current form” actions.

Other Settings

Aside for the form creation, there are other settings that you can adjust within the “Form Settings” menu. If you are only creating a simple form – like Submission Form – you can just leave everything as it is with the default value. But to make sure, you might want to check the email options to confirm that the email address where the submitted form will be sent is correct.

03e Form Settings - More Options.png

There are two other settings that you might want to adjust: the “Global Settings“,

04 Global Settings.png

And the “Form Styling” where you can pick the appearance of your form(s) from the pre-made templates, and edit the CSS if you want to.


Choose one of the styles and click the “Select Style” button, and you can see a preview of what your form will look like.

05b Choose Style And Preview.png

Last but not the least, “Help” is always there to guide you through the difficult times.

06 Help.png

Inserting The Form

You can insert the form into your blog post, pages and even as a widget. All you have to do is to click the cformsII button;


And pick the form that you want to insert.


If you want to use the widget, go to the “Appearance – Widgets” menu then drag and drop the cforms widget to the Widgets area.

08c Widgets cforms.png

And here’s an example of the published form.


What’s Going On Behind The Curtain?

What will happen after somebody clicks “Submit“? The content of the filled form will be emailed to the owner of the blog (or to another preferred address). The plugin comes with its own mailing system called PHPMailer.

09 PHPMailer.png

In a normal WP environment, you do not need to configure anything. Just leave it be and it will work. But if your web hosting provider doesn’t support the native PHP “mail()” command, you can configure cformsII to utilize external SMTP server such as GMail. You can configure the settings under “Global Settings – Mail Server Settings” menu.

And as for the mail address(es) where cformsII should send the filled forms to, is configurable under “Forms Setting – Admin Email Message Options” menu.

create a registration form

A registration form is just one application of the many possibilities provided by the powerful cformsII. So if you ever need to add forms to your WordPress blog, you can try cformsII and modify it to your needs.

Do you use forms in your blog? What kind of forms are they? What plugin do you use? Please share your experiences using the comment section below.