Adding Product Image to mp_category.php

Is there a way to add a product image to mp_category.php? At the moment I have <?php the_content(); ?> and it shows the text description, but I can't get the image to show inside the loop. I have tried <?php mp_product_image(); ?> to no avail.

  • Sajid

    Hi @marcusvmonroe05,

    Hope you are doing good today :slight_smile:

    Try using below code instead of the mp_product_image function. There are some changes in the code after 3.x.

    $product = new MP_Product();
    
    			$align = null;
    			if ( 'list' == mp_get_setting( 'list_view' ) ) {
    				$align = mp_get_setting( 'image_alignment_list' );
    			}
    $img = $product->image( false, 'list', null, $align, true );

    This should be within the loop and use below code where you want to display the image.

    ` <div class="mp_product_images">
    <?php echo $img; ?>
    </div><!-- end mp_product_images -->`

    Hope that helps! Feel free to post a reply if you need further assistance :slight_smile:
    Cheers, Sajid

  • Marcus

    //UPDATE//
    For some reason, my product's tags are picking up my mp_category.php template file instead of my mp_tag.php template file.

    I used the same file content for mp_category.php and mp_tag.php, so the code you supplied me above works to display the image of the product when you visit a tag url, but does not display a product image when you visit a category url.

    So the code above works, but does not seem to want to show an image for categories, which is frustrating that its using mp_category.php for tag urls and works to display the image.

  • Marcus

    Also... would the above code be more user friendly this way:
    '<?php $product = new MP_Product();
    $align = null;
    if ( 'list' == mp_get_setting( 'list_view' ) ) {
    $align = mp_get_setting( 'image_alignment_list' );
    $view = 'list';
    } elseif ( 'grid' == mp_get_setting( 'grid_view') ) {
    $align = mp_get_setting( 'image_alignment_grid' );
    $view = 'grid';
    }

    $img = $product->image( false, $view, null, $align, true ); ?>'

  • Marcus

    Really? Where is the support that I'm paying for? Your software is messing up and not functioning the way it is suppose to, a little help in finding a resolution should not be too much to ask for.

    I can't get the product image to display in the loop on the mp_category.php page template. The above code that was taken from template-functions.php does not work in displaying the image of the product in the loop. Since there are several issues with how the new product image is displayed, (single image, multiple images with slides, and variations of images based on product variations) it seems I need to get an answer from a developer who knows how they constructed their software and how it will need to work in order to call the image properly.

    Now, can I get some help?

  • Sajid

    Hi @marcusvmonroe05,

    Hope you are doing good today :slight_smile:

    I am sorry for delay on this ticket.

    First of all make sure you have enabled the show image on category products page from Store Settings > Presentation > Product List/Grid Settings > Show Product Thumbnail?

    If its enabled and still not working then I would need to take closer look at your template structure and how its loading the templates. For this purpose I would need FTP and WordPress admin login credentials (but don't post here). You can send in these credentials using our private contact form in following format.

    Subject: "Attn: Sajid Javed"
    -WordPress admin username
    -WordPress admin password
    -login url
    -FTP credentials (host/username/password)
    -link back to this thread for reference
    -any other relevant urls

    Select "I have a different question" for your topic - this and the subject line ensure that it gets assigned to me

    https://premium.wpmudev.org/contact/

    For future reference please avoid posting multiple replies in a thread instead post one consolidated reply and wait for the staff to respond. Our system feeds ur threads from oldest to newest so whenever you post a new reply it consider it a new post and pushes it to bottom of the queue. Its definitely not an excuse but explanation of how our system works.

    Take care and have a fantastic day :slight_smile:
    Cheers, Sajid

  • Marcus

    I appreciate the explanation Sajid, and pardon my frustration as I needed this to work and now am past a deadline.

    I do have checked the "Show Thumbnails" under the Product List/Grid Settings, even rechecked and resaved to make sure, no change. Tags page is still pulling mp_category.php as template page, image code works on tags page pulling category template, but images not showing up on actual /category/.. page.

  • Marcus

    Sajid @luiscarloslopes:

    Here is my more pressing matter, I have products with categories and tags. So I created custom template pages (mp_category.php & mp_tag.php). When a user clicks on a category, they are brought to a category page that shows all products in that same category. The same is done for product tags. All of my links work and I am brought to the right pages; ie. categories to ...store/products/category/category-slug and tags to ...store/products/tag/tag-slug for their corresponding attributes. The problem lies within the fact that ..store/products/tag/tag-slug page, uses mp_category.php instead of mp_tag.php as a template, and displays the image of the product with no issue, but a ..store/products/category/category-slug page, (/category/ actually uses the correct MP template file mp_category.php) does not show an image for the product at all. It instead falls back to the default place holder image.

    I can't seem to figure out why tag slugs are using mp_category.php as a template, with the images showing, yet category slugs, which are using the correct template file, doesn't show product images.

  • Sajid

    Hi @marcusvmonroe05,

    Hope you are doing good today :slight_smile:

    I am sorry for delay on this ticket. I have figured out why MarketPress products images are not displaying on mp_category.php. Its because you are loading the category products within the default category loop. When I simply added the mp_list_products(); without default loop it started displaying images. Yes, its not normal so I am reporting this issue to the developer.

    I have renamed your mp_category.php template to original_mp_category.php template so you can restore or get some code from it.

    Secondly, I could replicate the mp_tag.php template not being loaded for tags on my own website. Therefore I am marking it as confirmed bug and reporting developer so it can be fixed in upcoming version of this plugin. I am sorry but I am unable to provide firm ETA of exactly when it will be added (I will request developers to provide a patch meanwhile, if possible).

    Thanks for bringing in our attention and being a valuable member :slight_smile:
    Cheers, Sajid

  • Denitsa

    Hello Damo,
    I hope you're having a beautiful day and I'm sorry for the delay on our end !

    Can you please create a new support ticket for your question or issue (using this link https://premium.wpmudev.org/forums/#question), especially since this is an older topic? That way, the original poster does not get notification emails for something unrelated to his/her question and you'll be able to get answers more quickly, since fresh new threads have high priority (posting in a thread several times on a row puts it at the end of the queue though).

    This should be fixed in the latest release of the plugin, so your issue might actually be caused by something else. Please give a detailed explanation in your new thread.

    Cheers,
    Denitsa

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.