lcsternstrategy
Forum Replies Created
-
Forum: Plugins
In reply to: [Favorites] Email list of favoritesI don’t have any special settings in the form, but I can copy and paste what I have in my theme.
Here is my page-booksmarks.php:
<?php get_header(); ?> <div class="container-wrap"> <div class="container main-content"> <div class="row bookmarks"> <div class="col span_12 section-title blog-title"> <h1> <?php the_title(); ?> </h1> <a href="/contact?id= <?php /** * Method 2: WP_Query Object * Check if there are favorites before instantiating the WP_Query. * Passing an empty array as an argument returns ALL posts. * @see https://codex.www.ads-software.com/Class_Reference/WP_Query#Post_.26_Page_Parameters */ $favorites = get_user_favorites(); if ( $favorites ) : // This is important: if an empty array is passed into the WP_Query parameters, all posts will be returned $favorites_query = new WP_Query(array( 'post_type' => 'speakers', // If you have multiple post types, pass an array 'posts_per_page' => -1, 'ignore_sticky_posts' => true, 'post__in' => $favorites, 'paged' => $paged // If you want to include pagination, and have a specific posts_per_page set )); if ( $favorites_query->have_posts() ) : while ( $favorites_query->have_posts() ) : $favorites_query->the_post(); // Treat this like any other WP loop ?> <?php the_title(); ?>, <?php endwhile; next_posts_link( 'Older Favorites', $favorites_query->max_num_pages ); previous_posts_link( 'Newer Favorites' ); endif; wp_reset_postdata(); else : // No Favorites ?> You don't have any bookmarks yet. <? endif; ?> " class="blue-button contact-all"><i class="fa fa-comment fa-2x"></i>Inquire About Bookmarked Speakers</a> </div> <div class="clear"></div> </div> <div class="row list"> <?php /** * Method 2: WP_Query Object * Check if there are favorites before instantiating the WP_Query. * Passing an empty array as an argument returns ALL posts. * @see https://codex.www.ads-software.com/Class_Reference/WP_Query#Post_.26_Page_Parameters */ $favorites = get_user_favorites(); if ( $favorites ) : // This is important: if an empty array is passed into the WP_Query parameters, all posts will be returned $favorites_query = new WP_Query(array( 'post_type' => 'speakers', // If you have multiple post types, pass an array 'posts_per_page' => -1, 'ignore_sticky_posts' => true, 'post__in' => $favorites, 'paged' => $paged // If you want to include pagination, and have a specific posts_per_page set )); if ( $favorites_query->have_posts() ) : while ( $favorites_query->have_posts() ) : $favorites_query->the_post(); // Treat this like any other WP loop ?> <div class="bookmark-list"> <a href="<?php the_permalink(); ?>"> <?php the_post_thumbnail('speaker-thumb'); ?> </a> <div class="info"> <a href="<?php the_permalink(); ?>"><h3><?php the_title(); ?></h3></a> <p><?php the_excerpt(); ?></p> <?php the_favorites_button($post_id, $site_id); ?> </div> <div class="clear"></div> </div> <!-- end .post-excerpt --> <?php endwhile; ?> </div> <?php gravity_form( 2, false, false, false, '', true ); endif; wp_reset_postdata(); else : // No Favorites ?> You don't have any bookmarks yet. <? endif; ?> </div><!--/row--> </div><!--/container--> </div> <?php get_footer(); ?>
functions.php:
/** * Allow a user to email a list of favorites * @link https://www.gravityhelp.com/documentation/article/gform_notification/ */ add_filter( 'gform_notification_2', 'email_favorites_list', 10, 3 ); function email_favorites_list($notification, $form, $entry) { // Get the user's favorites and create a list $favorites = get_user_favorites(); if ( !$favorites ) return $notification; $fq = new WP_Query(array( 'post_type' => 'speakers', 'posts_per_page' => -1, 'post__in' => $favorites )); if ( $fq->have_posts() ) : // Styles should be set inline for display in email clients $list = '<div style="max-width: 550px; margin: 0 auto; padding: 50px 0;">'; $list .= '<img src="" width="345px" height="113px" style="margin-bottom: 30px;" alt="">'; $list .= '<p style="font-family: Open Sans, sans-serif; margin-bottom: 50px; line-height: 20px;">Below is your list of bookmarked speakers.</p>'; while ( $fq->have_posts() ) : $fq->the_post(); $list .= '<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700" rel="stylesheet" type="text/css">'; $list .= '<div class="bookmark-list" style="border-bottom: solid 1px rgba(55, 47, 53, 0.3); margin-bottom: 10px; padding-bottom: 10px;">'; //$list .= '<div class="photo">' . get_the_post_thumbnail(get_the_id()) . '</div>'; $list .= '<h3 style="font-family: Open Sans, sans-serif; text-transform: uppercase; font-size: 18px; line-height: 28px;">' . get_the_title() . '</h3>'; $list .= '<p style="font-family: Open Sans, sans-serif;">' . get_the_excerpt() . '</p>'; $list .= '<a href="' . get_the_permalink() . '" style="font-family: Open Sans, sans-serif; color: #00afbb; padding: 10px 15px; border: solid 1px #00afbb; font-size: 12px; line-height: 12px; display: inline-block; text-decoration: none;">View Speaker</a>'; $list .= '</div>'; endwhile; $list .= '</div>'; $list .= '<div class="footer" style="width: 96%; background: #f8f8f8; padding: 20px 2%;"> <p style="max-width: 550px; margin: 0 auto; font-family: Open Sans, sans-serif; font-size: 12px; line-height: 18px; text-align: center;">Copyright ? 2015, All rights reserved.?</p> </div>'; else : return $notification; endif; wp_reset_postdata(); // Append the list to the notification message $notification['message'] = $list; // Change the to address to the user-specified email (this will change depending on your form) $notification['subject'] = __('Your Bookmarked Speakers', 'textdomain'); // Name Field return $notification; }
Forum: Plugins
In reply to: [Favorites] Email list of favoritesAndrew,
I used the code provided by Kyle almost exactly. I don’t think I added code anywhere else to get this working for me. I’m not sure if I could be of much assistance, but an example of the code you’re using may help Kyle troubleshoot the issue.
Forum: Plugins
In reply to: [Five Star Restaurant Menu and Food Ordering] Menu ThumbnailNate,
Thanks for the quick response! That code as is actually worked perfectly to add a thumbnail to the menu! Cheers!
I had the same problem as well and had to stop using Types. Hopefully there’s a fix for this. It’s an issue with the break; statement in php 7.
Forum: Plugins
In reply to: [Favorites] Email list of favoritesKyle,
This is working great for me! Thank you so much for the quick responses and I hope this ends up helping a lot of people with a similar request.
Forum: Plugins
In reply to: [WP Favorite Posts] Add Favourite Posts to form?I have this exact same question also using Gravity Forms! Thanks for asking.