Code Food Travel repeat!

List posts by taxonomy

List custom post types by taxonomy term.
List Posts For Terms Of A Custom Taxonomy For Any Post Type

I used this on a client website to list posts tagged by year.

Ie:
1940
-post 1
-post 2
1941
-post 3
-post 4…

I scoured the internet for a good working solution and there are so many that don’t work, this this simply did. Cut n paste. Originally written by nickam.



<?php
$post_type = 'filmography';
$tax = 'film-year';
$tax_terms = get_terms($tax,'hide_empty=0');

//list the taxonomy
$i=0; // counter for printing separator bars
foreach ($tax_terms as $tax_term) {
$wpq = array ('taxonomy'=>$tax,'term'=>$tax_term->slug);
$query = new WP_Query ($wpq);
$article_count = $query->post_count;
echo "<a href=\"#".$tax_term->slug."\">".$tax_term->name."</a>";
// output separator bar if not last item in list
if ( $i < count($tax_terms)-1 ) {
echo " | " ;
}
$i++;
}

//list everything
if ($tax_terms) {
  foreach ($tax_terms  as $tax_term) {
    $args=array(
      'post_type' => $post_type,
      "$tax" => $tax_term->slug,
      'post_status' => 'publish',
      'posts_per_page' => -1,
      'caller_get_posts'=> 1
    );

    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      echo "<h2 class=\"tax_term-heading\" id=\"".$tax_term->slug."\"> $tax_term->name </h2>";
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        <?php
      endwhile;
      echo "<p><a href=\"#top\">Back to top</a></p>";
    }
    wp_reset_query();
  }
}
?>

Display wordpress custom taxonomy with separators and title attribute

I was looking and having trouble finding a function that would not only return my custom taxonomy terms, but with the title description attribute so that when people hover over the link they get some more info.

Get_the_terms_list function did half of what I wanted – I got the custom taxonomy plus a separator if more than one, but no description:

			<?php echo get_the_term_list( $post->ID, 'film-year', '', ', ', '' ); ?>

So here is my solution:

			<?php
			$terms = get_the_terms( $post->ID, 'film-year' );

			if ( $terms && ! is_wp_error( $terms ) ) : 

				$year_links = array();

				foreach ( $terms as $term ) {
				    $term_name = $term->name; // get the ID of the term
							$year_links[] = '<a href="'.get_term_link($term).'" title="View all films from '.$term_name.'">'.$term_name.'</a>';
				   
				}

				$filmyearlinks = join( ", ", $year_links );
			?>

			<p>
				Film year: <span><?php echo $filmyearlinks; ?></span>
			</p>

			<?php endif; ?>

Enjoy!

Gravity Forms not sending email to Google Apps

After struggling with this first on client websites, and then on my personal website- I was trying to figure out why Gravity Forms is a recommended plugin for WordPress contact forms?! FINALLY a solution. The emails don’t go to the inbox of Google Apps. I have no idea why, but you can route it FIRST to a GMAIL, THEN back to GOOGLE Apps.

This is how you do it:

Setting up your notification page


1. Go to EDIT FORM -> [select your form] -> NOTIFICATIONS
2. Under Send to email: email, put a gmail address (I’m assuming that your administrator email is a google apps email address and not working, which is why you are reading this blog entry in the first place)
3. From Email: you can use your gmail or your google apps email. I used my google apps. I’m not sure I would recommend using the Email value from the form, because this gmail Address Book would just get filled up with random people’s email addresses who are contacting you. I set mine to my own so that if I want to respond, I have their email address and only then does it get logged in my Address Book.
4. Create a distinct email subject title. You will use this to create a filter on your gmail email to send it back to google apps. Mine is: “New STEVENCHU.COM submission from {form_title}” –> my filter will be “New STEVENCHU.COM submission”

Forwarding Gmail back to Google Apps


1. Start a search with the first few words of your email submission form but instead of searching, click CREATE A FILTER.
2. Add a forwarding address. Type in your google apps email address, submit. Go to google apps and verify the link sent to your email. Forwarding is now enabled. Go back to Gmail
3. Check delete email & forward email to [your google apps email].
4. Save this filter.

Testing Gravity Forms

1. Go back to your webpage and try submitting the form again. See if you get an email notification that comes through to your Google Apps. It should come through and the FROM field will say “to [google apps email] via gmail.com

Good luck! Let me know if this works for you.

How to get to Rockaway Beach, New York

1. Take the Far Rockaway bound A train (If you are on the Lefferts Blvd, you can transfer at Rockaway Blvd)
2. Transfer at Broad Channel to the S shuttle on the same platform- you don’t need to go anywhere.
3. Take shuttle 1 – 3 stops (these are the main stops for the beach). The first stop is probably the most popular- it has beach goers and surfers.
4. On exit, walk to the street corner in front of you, take a left turn and walk until you hit the beach.
5. In the surfing only areas, you can’t swim.. but after the first 2 or 3 wood separator areas, you will see people swimming.

Good luck! have fun

8 of 27
456789101112
%d bloggers like this: