MarketPress: Need help understanding templating Marketpress


I have read Themeing_MarketPress.txt and understand that I can name a file mp_product.php in order to create a new template for the product page (for example). From reading other questions on this in this forum I understand that the theme file single.php is the "starting point" for this..

Before creating mp_product.php, everything looks *almost* perfect as it is; I just need to make a slight change. I have started by simply renaming single.php as mp_product.php, so that I can use that as a starting point for just some slight adjustments. However, when I do this, almost nothing that shows up on the product page normally, disappears: no image, no "add to cart" button. There is just the Title and Description.

Now, I understand that you can include the functions from template-functions.php to create your own template. However, if I want to add the image back in after it has mysteriously disappeared, I assume that I am to copy the code from "* Displays the product featured image" (function mp_product_image, about line 1596). However...I don't understand WHERE this goes on my new mp_product.php or really how to integrate it.

My mp_product.php is basically this:


get_template_part( 'loop', 'single' );

So, where, within that, would I put function mp_product_image? I have tried inserting it in many different places (yes, within the PHP brackets), but no matter where I put it, I get errors such as:

Fatal error: Cannot redeclare mp_product_image() (previously declared in /usr/www/users/mccmhost/pechepassion/wp-content/plugins/marketpress/marketpress-includes/template-functions.php:1603) in /usr/www/users/mccmhost/pechepassion/wp-content/themes/pechepassion/mp_product.php on line 98

More importantly, for user friendliness and easy templating why did you not simply provide a mp_product.php file for us that we could edit?? Urgh. I truly do not understand the methodology for templating Marketpress and I very much need some RAPID help! Thank you.

  • 3SixtyEvolve

    Hi @immeemz

    Greetings from the WPMU DEV Support Team and thank you for being a member.

    I feel your frustration. I will look into the theming functions and provide you with some guidelines at the earliest. I do understand that it can be quite complicated dealing with the different codes, so I will try to simplify it for you. Allow me some time to get back to you.

    In the meantime, if you need any further assistance, please don't hesitate to be in contact.

    Have a good day!


  • Aaron

    why did you not simply provide a mp_product.php file for us that we could edit??

    It's not possible to do that as every theme is different. As far as how hard it is to customize, it works just like WP themeing, so any developer with familiarity with building/customizing themes should have no trouble.

    In your case your theme keeps it's loop in another template file
    get_template_part( 'loop', 'single' );
    So you would need to grab the loop code from that file and merge it back into your template. Then you can add the appropriate template functions.

    Here is an example of what's in the default loop:

    mp_product_image( true, 'single' );
    mp_buy_button(true, 'single');
    echo mp_category_list($post->ID, '<div class="mp_product_categories">' . __( 'Categorized in ', 'mp' ), ', ', '</div>');

    Overall though it sounds to me like you don't really have the technical familiarity with WP themes for this, it would probably be best to get a developer to help you with this. It's not something we can just tell you how to do, it's very specific to your theme and requirements.

  • Adam Apollo

    For others who have this same issue and find this thread, here's some working code that you can insert in your page.php that you have copied and made into mp_product.php :::

    <?php mp_product_description($product_id, $echo = true, $content = 'full', $html_tag = true, $css_class = 'mp_product_content', $microdata = 'itemprop="description"') ?>

    <?php mp_product_meta($echo = true, $context = 'single', $label = true, $product_id = null, $html_tag = true, $css_class = 'mp_product_meta') ?>

    Follow the same pattern for any other item in template-functions.php... Take the first line of code under the commented descriptions (example here is * function mp_product):

    function mp_product($echo = true, $product_id, $title = true, $content = 'full', $image = 'single', $meta = true)

    Copy everything but the word function and the curly bracket at the end of the line {

    Then place that inside of PHP tags inside your template:

    <?php mp_product($echo = true, $product_id, $title = true, $content = 'full', $image = 'single', $meta = true) ?>

    Then replace items inside that code with information from the parameters in the commented code:

    * @param bool $echo Optional, whether to echo or return
     * @param int $product_id the ID of the product to display
     * @param bool $title Whether to display the title
     * @param bool/string $content Whether and what type of content to display. Options are false, 'full', or 'excerpt'. Default 'full'
     * @param bool/string $image Whether and what context of image size to display. Options are false, 'single', or 'list'. Default 'single'
     * @param bool $meta Whether to display the product meta

    That should do it!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.