WordPress.org

Forums

WordPress prettyPhoto
[resolved] Sample of how to use your WordPress prettyPhoto (7 posts)

  1. Amber
    Member
    Posted 2 years ago #

    How can I get my images/galleries on page/posts/custom post types to trigger your prettyPhoto plugin.

    Do you have sample of code to add to functions.php in a theme file for this since it requires adding rel="prettyPhoto" to images and there is no way to do that by default in WordPress currently.

    http://wordpress.org/extend/plugins/prettyphoto/

  2. Babar
    Member
    Plugin Author

    Posted 2 years ago #

    If you go for functions.php method all your images and links will open in prettyphoto by default.
    I think it's not a good idea, that's why I haven't implemented that.

    You can simply add the rel="prettyPhoto" tag with the image links you want to open with rettyphoto.

  3. Amber
    Member
    Posted 2 years ago #

    I'm unable to add rel="prettyphoto" to images that are embeded using the default WP Gallery feature. Galleries are added via a shortcode. How can I get your plugin to work with the default WP Galleries?

  4. Babar
    Member
    Plugin Author

    Posted 2 years ago #

    No way for now.
    You will have to write markup manually.
    Or if you are proficient with php you may write a filter function to override default WordPress gallery shortcode.

  5. Amber
    Member
    Posted 2 years ago #

    It actually seems to be not working at all for any image.

    If you see the following url you can see that even though your plugin is active and the rel=prettyPhoto is applied it's not working: Test

  6. Babar
    Member
    Plugin Author

    Posted 2 years ago #

    Your theme doesn't have any jQuery included.
    Please include jQuery => 1.8.3 on your theme header to use prettyPhoto.

  7. Amber
    Member
    Posted 2 years ago #

    o_O Talk about a blonde moment; this is a sign that working at 3am is bad. I didn't even realize that jQuery was not being included in Twenty Twelve I just assumed it was.

    Derp! Enqueued jQuery in the Twenty Twelve functions and all is good now. :)

    As a side note, after a bit of googling if anyone else wants to use your plugin with galleries they can use the following in their functions.php (courtesy of Remi Corson):

    /* ------------------------------------------------------------------*/
    /* ADD PRETTYPHOTO REL ATTRIBUTE FOR LIGHTBOX */
    /* ------------------------------------------------------------------*/
    
    add_filter('wp_get_attachment_link', 'rc_add_rel_attribute');
    function rc_add_rel_attribute($link) {
    global $post;
    return str_replace('<a href', '<a rel="prettyPhoto[pp_gal]" href', $link);
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WordPress prettyPhoto
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.