• Hey all,

    I was wondering if anyone had any tips on how to duplicate a whole module in a template?

    For example when I am on the wordpress dashboard for the admin area of my website, all links to the left… On the template I am using the author (who unfortunately disappeared) created 3 additional buttons / links there… One for services, one for portfolio, one for team members… If you click on one of them it will bring you to a page that works exactly like the posts page…

    Now I am thinking that if I just duplicate the services.php page and rename it location-services.php and then change any code in the doc where it says services to location-services…

    But I have a feeling its not that easy… Would anyone have any advice?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Action Turtle

    (@benjaminbernard)

    Yea so just duplicating that document and renaming it was not enough…

    One clue might be that when I am working with the nav menu… You know how you add links from the left to the menu… There are the usual ones, pages, links, categories, post archive… But now there are three additional ones all called item…

    I would guess maybe there is some code I have to duplicate and rename in my functions.php

    Thanks for any help with this…

    Thread Starter Action Turtle

    (@benjaminbernard)

    Found the code that I think I needed to duplicate and change… But when I did I got fatal errors back on the lines that I had changed…

    All the places that say “location-services” used to just say “services” and I appended the “location-” on to it… … Here is the code that I have… Any help would be huge… Thanks so much ??

    add_action('init', location-services_custom_init');  
    
    	/*-- Custom Post Init Begin --*/
    	function location-services_custom_init()
    	{
    	  $labels = array(
    		'name' => _x('Items', 'post type general name', 'playne'),
    		'singular_name' => _x('Item', 'post type singular name', 'playne'),
    		'add_new' => _x('Add New', 'member', 'playne'),
    		'add_new_item' => __('Add New Item', 'playne'),
    		'edit_item' => __('Edit Item', 'playne'),
    		'new_item' => __('New Item', 'playne'),
    		'view_item' => __('View Item', 'playne'),
    		'search_items' => __('Search Items', 'playne'),
    		'not_found' =>  __('No Items found', 'playne'),
    		'not_found_in_trash' => __('No Items found in Trash', 'playne'),
    		'parent_item_colon' => '',
    		'menu_name' => 'Location Services'
    
    	  );
    
    	 $args = array(
    		'labels' => $labels,
    		'public' => true,
    		'publicly_queryable' => true,
    		'show_ui' => true,
    		'show_in_menu' => true,
    		'query_var' => true,
    		'rewrite' => true,
    		'capability_type' => 'post',
    		'has_archive' => true,
    		'hierarchical' => false,
    		'menu_position' => null,
    		'supports' => array('title','editor', 'thumbnail', 'custom-fields')
    	  );
    	  // The following is the main step where we register the post.
    	  register_post_type('location-services',$args);
    
    	}
    
    	add_filter('post_updated_messages', 'services_updated_messages');
    
    	function services_updated_messages( $messages ) {
    	  global $post, $post_ID;
    
    	  $messages['services'] = array(
    		0 => '', // Unused. Messages start at index 1.
    		1 => sprintf( __('Service updated. <a href="%s">View service</a>'), esc_url( get_permalink($post_ID) ) ),
    		2 => __('Custom field updated.', 'playne'),
    		3 => __('Custom field deleted.', 'playne'),
    		4 => __('Service updated.', 'playne'),
    		/* translators: %s: date and time of the revision */
    		5 => isset($_GET['revision']) ? sprintf( __('Service restored to revision from %s', 'playne'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
    		6 => sprintf( __('Service published. <a href="%s">View item</a>'), esc_url( get_permalink($post_ID) ) ),
    		7 => __('Item saved.', 'playne'),
    		8 => sprintf( __('Service submitted. <a target="_blank" href="%s">Preview service</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
    		9 => sprintf( __('Service scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview service</a>'),
    		  // translators: Publish box date format, see https://php.net/date
    		  date_i18n( __( 'M j, Y @ G:i', 'playne' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),
    		10 => sprintf( __('Service draft updated. <a target="_blank" href="%s">Preview service</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
    	  );
    
    	  return $messages;
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to duplicate whole module in template?’ is closed to new replies.