-3

I need to create a Wordpress Custorm Post Type with the following fields, I am not a developer and would appreciate a cut and paste. The Fields are:

Contact Person, Address, Telephone, Cellphone, Fax, Email, Website

HELP

2

3 Answers 3

3

I think you have misunderstood what Custom Post Types are used for, if your trying to gather data try a plugin called Contact-Form-7 or if you want to post data then try using custom fields with the name of Contact Person, Address, Telephone, Cellphone, Fax, Email, Website.

You can echo custom fields into your theme files with the following code:

<?php $custom_field = get_post_meta($post->ID, 'custom-field-name', $single = true); ?>
<?php echo $custom_field  ?>

if you add a custom field called: 'contact-name' then you can setup the code to echo the data as follows;

<?php $contact_name = get_post_meta($post->ID, 'contact-name', $single = true); ?>
    <?php echo $contact_name ?>
3
  • Thanks Xavier, I understand the custom field format, but I want to register and display a new 'custom post type' and call it Organization, which will have posts with the above mentioned values (i.e. Contact Person, Address, Telephone, Cellphone, Fax, Email, Website.) and the title, content and featured image. Hope I have better explained myself, can you help?
    – Zeal
    Apr 1, 2011 at 11:33
  • Why do you need a custom post type? If you are a newbie to coding and wordpress i wouldn't recommend using Custom Post Types at all as they are much harder to work with, just add a category under Posts and name it "Organisations" then to all posts under "Organisations" just add custom fields to those posts All you have to do from there is query a category to display the data.
    – Xavier
    Apr 1, 2011 at 17:15
  • Also your website states the following majoring in wordpress development, graphic design for web and print So i have agree with @Roman Wünsche if you want someone to provide you the "majoring" that your website claims then pay a fee for it.
    – Xavier
    Apr 1, 2011 at 17:21
1

The easiest way for non developers to create custom post types is to use the Custom Post Type UI plugin.

That said, I don't think custom post types are what you really want, do you really want to show Person, Address, etc on separate pages? What are you actually trying to achieve?

0

You would need to add the custom post type in a plugin file, like this

add_action( 'init', 'create_post_type' );


function create_post_type() {

register_post_type('file', array(
    'label' => __('Organizations'), // e.g. apples
    'singular_label' => __('Organization'), // e.g. apple
    'public' => true,
    'show_ui' => true, // UI in admin panel
    '_builtin' => false, // It's a custom post type, not built in!
    '_edit_link' => 'post.php?post=%d',
    'capability_type' => 'post',
    'hierarchical' => false,
    'rewrite' => array("slug" => "YOURNAME"), // Permalinks format
    'supports' => array('title','author','custom-fields','comments' )
));

}

See for full possible options this page register post type

Then to add each field to the post type, you could use post meta.

add_post_meta($post_id, YOURMETANAME, YOURVALUE);
add_post_meta($post_id, 'Name', 'John Doe');

which you can retrieve with:

get_post_meta($post_id, YOURMETANAME, YOURVALUE);
get_post_meta($post_id, 'Name', 'John Doe');

This can't be done with simple copy/pasting, it will require some work from your side...

4
  • Thanks Jan, I managed to register the custom post, now I need the meta data for it, what's the next step, thanks for spoon feeding me.
    – Zeal
    Apr 1, 2011 at 14:41
  • 2
    @Zeal: Don't get me wrong, but do you really expect that someone code the whole project for you? JanWillem give you some examples and suggestions. If you aren't a programmer, ask someone and pay a small fee for a solution.
    – Roman
    Apr 1, 2011 at 15:26
  • 1
    Your usage of __() is pointless: WordPress doesn’t have the string 'Organizations' in its default language file.
    – fuxia
    Jun 3, 2011 at 10:17
  • 1
    @Zeal see also metabox tag
    – Michal Mau
    Jun 3, 2011 at 11:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.