- This topic is empty.
-
AuthorPosts
-
August 13, 2012 at 11:50 am #39359KralleParticipant
Hello guys!
I’m working on a site where I’d like to add some testimonials and list them all in a page. It should be fairly simple, I don’t have any need for a widget, carousel or anything like that, just a plain list of testimonials. I wish to add each testimonial via Custom Post Types, and so far I can see/add/edit/delete each testimonial with this in my functions.php file:
add_action( 'init', 'kundeudtalelse_post_type' );
function kundeudtalelse_post_type() {
register_post_type( 'kundeudtalelse',
array(
'labels' => array(
'name' => __( 'Kundeudtalelser' ),
'singular_name' => __( 'Kundeudtalelse' ),
'add_new' => __( 'Tilføj ny' ),
'add_new_item' => __( 'Tilføj ny kundeudtalelse' ),
'edit' => __( 'Rediger' ),
'edit_item' => __( 'Rediger kundeudtalelse' ),
'new_item' => __( 'Ny kundeudtalelse' ),
'view' => __( 'Se kundeudtalelse' ),
'view_item' => __( 'Se kundeudtalelse' ),
'search_items' => __( 'Søg kundeudtalelse' ),
'not_found' => __( 'Ingen kundeudtalelse fundet' ),
'not_found_in_trash' => __( 'Ingen kundeudtalelser fundet i papirkurven' ),
'parent' => __( 'Forældre til kundeudtalelse' ),
),
'public' => true,
'has_archive' => true,
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => array('slug' => 'kundeudtalelser'),
'query_var' => true,
)
);
}What I would like to have is a few custom fields in each post, where I can put name of the contact person, company name and perhaps the website URL for the company. Could anybody show me how that would be done?
Furthermore I was wondering if it’s possible to list all these testimonial in a page with a shortcode or a page template. I’ll be forever grateful, if somebody could help me with this.
I’m using the latest WordPress version, and it would be great if I could avoid using a plugin. Thanks in advance.
Best regards.
August 13, 2012 at 2:07 pm #107854TheDocMemberI’ve always used this plugin: http://advancedcustomfields.com/
I think it’s fantastic.
August 14, 2012 at 7:24 am #107906KralleParticipantI really did not want to use a plugin, but that one is doing amazingly well! Thanks a bunch, TheDoc.
Could you or someone else tell me how to list the custom post types in a page via a short code or a page template?
Thanks in advance.
August 15, 2012 at 2:49 am #107948KralleParticipantThanks a lot, jamy_za. I think that snippet is quite easy to grasp.
Although, when I put this in my page template-file (and make the page use this template in the admin panel), it’s not using that template – instead it shows the index.php content. What am I doing wrong?
I’m sorry for all these questions, but I can’t seem to figure it out. Thanks in advance.
August 15, 2012 at 6:15 am #107951KralleParticipantI found out that the slug I’m using in the custom post type is causing problems with the page, since they’re using the same. Case solved! Thanks a lot guys, you saved me from a complete headache.
August 17, 2012 at 10:33 am #108033Historical Forums UserParticipantHey Kralle,
I just released a plugin for this called PostTypeFactory. I haven’t looked at the advanced custom fields plugin (which I will do now) but in my plugin, I have a built in short code to generate a list of whatever post types you create. Im working on the documentation now but you can check out the site and get the plugin here –Let me know if it works for you.
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.