Skip to content

Instantly share code, notes, and snippets.

@harshclimate
Created January 8, 2019 23:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harshclimate/1a3c8302933cfa7eae0309d7a1f08717 to your computer and use it in GitHub Desktop.
Save harshclimate/1a3c8302933cfa7eae0309d7a1f08717 to your computer and use it in GitHub Desktop.
<?php get_header(); ?>
<?php
$args1 = array(
'post_type' => 'post',
'orderby' => 'rand',
'category_name' => 'wineries',
'posts_per_page' => 1
); $wineries = new WP_Query($args1);
?>
<?php
$args2 = array(
'post_type' => 'post',
'orderby' => 'rand',
'category_name' => 'breweries',
'posts_per_page' => 1
); $breweries = new WP_Query($args2);
?>
<?php
$args3 = array(
'post_type' => 'post',
'orderby' => 'rand',
'category_name' => 'venues',
'posts_per_page' => 1
); $venues = new WP_Query($args3);
?>
<?php
$args4 = array(
'post_type' => 'post',
'orderby' => 'rand',
'category_name' => 'favorites',
'posts_per_page' => 1
); $favorites = new WP_Query($args4);
?>
<main class="home">
<div class="col-06">
<h3>arizona wineries</h3>
<?php if ($wineries->have_posts()) : while($wineries->have_posts()) : $wineries->the_post(); ?>
<?php if(has_post_thumbnail()) { ?>
<span class="item" style="background-image: url('<?php echo wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) ); ?>');"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">&nbsp;</a></span>
<?php
$trimtitle = get_the_title();
$shorttitle = wp_trim_words( $trimtitle, $num_words = 10, $more = '... ' );
echo '<h2><a href="' . get_permalink() . '">' . $shorttitle . '</a></h2>';
?>
<?php $content = get_the_content(); echo '<p>' . mb_strimwidth($content, 0, 310, ' ... ') . ' <a href=" ' . get_permalink() . ' ">more</a>' . '</p>'; ?>
<?php } else echo '<span class="item" style="background-image: url(\'http://www.harshclimate.com/wp-content/uploads/2019/01/arizonaflag.jpg\');"><a href="' . get_the_permalink() . '" title="' . get_the_title() . '">' . '&nbsp;' . '</a></span>'; ?>
<?php endwhile; else : '<p>Sorry, no winery posts have been added yet.</p>'; endif; ?>
<?php wp_reset_postdata(); ?>
</div>
<div class="col-06">
<h3>arizona breweries</h3>
<?php if ($breweries->have_posts()) : while($breweries->have_posts()) : $breweries->the_post(); ?>
<?php if(has_post_thumbnail()) { ?>
<span class="item" style="background-image: url('<?php echo wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) ); ?>');"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">&nbsp;</a></span>
<?php
$trimtitle = get_the_title();
$shorttitle = wp_trim_words( $trimtitle, $num_words = 10, $more = '... ' );
echo '<h2><a href="' . get_permalink() . '">' . $shorttitle . '</a></h2>';
?>
<?php $content = get_the_content(); echo '<p>' . mb_strimwidth($content, 0, 310, ' ... ') . ' <a href=" ' . get_permalink() . ' ">more</a>' . '</p>'; ?>
<?php } else echo '<span class="item" style="background-image: url(\'http://www.harshclimate.com/wp-content/uploads/2019/01/arizonaflag.jpg\');"><a href="' . get_the_permalink() . '" title="' . get_the_title() . '">' . '&nbsp;' . '</a></span>'; ?>
<?php endwhile; else : '<p>Sorry, no winery posts have been added yet.</p>'; endif; ?>
<?php wp_reset_postdata(); ?>
</div>
<span class="col-12"><p style="float: left; width: 100%; border-bottom: solid 1px #ccc; margin: 1em 0 2em 0;">&nbsp;</p></span>
<div class="col-06 store">
<h3>stores that carry arizona beverages</h3>
<?php if ($venues->have_posts()) : while($venues->have_posts()) : $venues->the_post(); ?>
<?php if(has_post_thumbnail()) { ?>
<span class="item" style="background-image: url('<?php echo wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) ); ?>');"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">&nbsp;</a></span>
<?php
$trimtitle = get_the_title();
$shorttitle = wp_trim_words( $trimtitle, $num_words = 10, $more = '... ' );
echo '<h2><a href="' . get_permalink() . '">' . $shorttitle . '</a></h2>';
?>
<?php global $post; $content = $post->post_content; echo '<p>' . mb_strimwidth($content, 0, 270, ' ... ') . ' <a href=" ' . get_permalink() . ' ">more</a>' . '</p>'; ?>
<?php } else echo '<span class="item" style="background-image: url(\'http://www.harshclimate.com/wp-content/uploads/2019/01/arizonaflag.jpg\');"><a href="' . get_the_permalink() . '" title="' . get_the_title() . '">' . '&nbsp;' . '</a></span>'; ?>
<?php endwhile; else : '<p>Sorry, no venue posts have been added yet.</p>'; endif; ?>
<?php wp_reset_postdata(); ?>
</div>
<div class="col-06 favorite">
<h3>azcork's national favorites</h3>
<?php if ($favorites->have_posts()) : while($favorites->have_posts()) : $favorites->the_post(); ?>
<?php if(has_post_thumbnail()) { ?>
<span class="item" style="background-image: url('<?php echo wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) ); ?>');"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">&nbsp;</a></span>
<?php
$trimtitle = get_the_title();
$shorttitle = wp_trim_words( $trimtitle, $num_words = 4, $more = '... ' );
echo '<h2><a href="' . get_permalink() . '">' . $shorttitle . '</a></h2>';
?>
<?php $content = get_the_content(); echo '<p>' . mb_strimwidth($content, 0, 270, ' ... ') . ' <a href=" ' . get_permalink() . ' ">more</a>' . '</p>'; ?>
<?php } else echo '<span class="item" style="background-image: url(\'http://www.harshclimate.com/wp-content/uploads/2019/01/arizonaflag.jpg\');"><a href="' . get_the_permalink() . '" title="' . get_the_title() . '">' . '&nbsp;' . '</a></span>'; ?>
<?php endwhile; else : '<p>Sorry, no winery posts have been added yet.</p>'; endif; ?>
<?php wp_reset_postdata(); ?>
</div>
</main>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment