0

I have created a review site where clients can rate their hosting providers based on various factors, however since the launch, many have asked if it would be possible to create a price comparison table so they could look for provider's in their price range.

I believe the best way to do this will be to create a Custom Post Type and have fields for the 5-10 most common packages, where I can create a new CPT entry for each provider and set the prices there (or even give the providers access to do so themselves).

Would this be the best way to go about this with Wordpress? How can I create a page that loops through each entry for that CPT and pulls the information I need to build this table?

1 Answer 1

1

I suggest just making a new Post Type with the default Wordpress register_post_type().

function create_my_post_type() {
$labels = array(
    'name'               => __( 'Providers pricing', 'myplugin_namespace' ),
    'singular_name'      => __( 'Provider pricing', 'myplugin_namespace' ),
    'menu_name'          => __( 'Provider Pricing', 'myplugin_namespace' ),
);

$args = array(
    'labels'       => $labels,
    'public'       => true,
    'description'  => __( 'Pricing stuff for my awesome plugin', 'myplugin_namespace' ),
    'show_in_menu' => true,
    'supports'     => array( 'title', 'thumbnail' ), // or whatever else you want from WP_Post
    'has_archive'  => true,
);
}

To be clear: this should be run during plugin initiation. To add custom meta-boxes for your fields, read up on the function add_meta_box()

2
  • Thanks for the response. I may not have been clear enough so I do apologize. I was getting more at how I could basically pull the information from any posts that were made with my actual CPT to display on a page. I made a CPT called "Packages" where I can list prices for each company, I just need to make a page and pull all of these for display. pastie.org/9703602 Commented Nov 7, 2014 at 21:09
  • You are making it quite difficult for yourself by calling all of the fields "meta-text". If you give them uniqe names, it's easy to get a hold of them using get_post_meta($post->ID, 'name-of-attribute')
    – Jimtrim
    Commented Nov 7, 2014 at 21:16

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.