Post emergency WordPress questions for fast help... ...Or answer questions first & win prize money.

$5
Photography website - using gallery & foxycart to sell products

I have a photographer client who I am building a website for. The client does a lot of wedding photography and the likes, and what he would like to be able to do is display the client a gallery of their photographs and allow them to order the ones they like, giving them the option of size, format, etc.

In my head, I thought the best way of doing this would be to somehow intercept the [gallery] output, so that for each image that is returned, I add the product options fields for Foxycart to use.

How would I go about doing this - or is there perhaps a better way of doing this that I haven't thought of?

Darfuria | 02/08/10 at 12:06pm | RSS Answers

(3) Possible Answers Submitted...

  • avatar
    Last edited:
    02/08/10
    12:14pm
    Utkarsh Kukreti says:

    You can fetch a list of the attachments using something like

    $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );


    You can get the attachment link using wp_get_attachment_link

    Some more useful functions are available at wp-includes/media.php

  • avatar
    Last edited:
    02/08/10
    1:07pm
    Ben Huson says:

    Have you thought about using any of the WordPress ecommerce plugins?
    I know WP e-Commerce can handle downloadable products like MP3 and probably images.

    • Darfuria says:

      As each of the purchasing options are going to be the same for every image, it'd be an unnecessarily lengthy process to use an eCommerce system and manually add each image as a product. FoxyCart is an ideal solution, I just need a way of intercepting the code generated by the [gallery] shortcode so that I can add the fields after each image.

  • avatar
    Last edited:
    02/09/10
    11:04am
    Dan Fraticiu says:

    You could mirror the [gallery] short code. And by mirror I mean simply copy it, you can find it here or in wp-includes/media.php function name gallery_shortcode().

    You paste that function in your functions.php file of your theme, change it's name with something like foxy_gallery_shortcode, then the shortcode like this:


    add_shortcode('foxy_gallery', 'foxy_gallery_shortcode');


    Now you should be able to add you custom code in the foreach that builds the gallery.

    • Darfuria says:

      This seemed like a viable solution, but unfortunately I'm getting the following error upon coping the function into my functions.php file and renaming it to foxy_gallery:


      Warning: Cannot modify header information - headers already sent by (output started at .../functions.php:114) in .../wp-includes/pluggable.php on line 865

This question has expired.