php - Wordpress: Getting Posts From A Category Using Category Name/Slug -
i trying display wordpress posts particular category, on non wordpress part of site, retrieving posts category name/slug.
please note, cannot use category id, because dynamically matching slug using category structure on non wp part of site.
the following works, seems retrieve posts category, rather united-states category. going wrong.
<div class="row"> <div class="small-12 columns"> <div class="row small-up-1 medium-up-3 large-up-3"> <?php require($_server['document_root'] . '/blog/wp-load.php'); $args = array( 'category_name' => united-states, 'posts_per_page' => 3 ); $latest_posts = new wp_query( $args ); if ( $latest_posts->have_posts() ) { while ( $latest_posts->have_posts() ) { $latest_posts->the_post(); ?> <?php $urli = get_permalink(); $remove = 'http://urlremoved.com/' ; $trimmed = str_replace($remove, '', $urli) ; ?> <div class="column"><div class="hppost"> <div class="image cover"> <a href="<?php echo $trimmed; ?>"><?php the_post_thumbnail(medium); ?></a> </div> <div class="title"> <a href="<?php echo $trimmed; ?>"><?php the_title(); ?></a> </div> <div class="desc"><?php the_excerpt(); ?></div> </div></div> <?php } } else { echo '<p>there no posts available</p>'; } wp_reset_postdata(); ?> </div> </div> </div>
Comments
Post a Comment