URL Rewrite and Archive Template Files – Post Type vs. Taxonomy

I handled this with a pre_get_posts hook (thanks, @Milo), passing in the URL part that corresponds to the slug I need. Hope this helps someone down the road. Improvements are welcome. Thanks. function filter_team_news_archives_by_sport_taxonomy($query) { if (is_post_type_archive(‘team-news’) && $query->is_main_query()){ // Get $sport_slug from URL — https://stackoverflow.com/a/36002190/4107296 $url = (isset($_SERVER[‘HTTPS’]) ? “https” : “http”) . “://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]”; … Read more

Get posts from category from custom query

I figured it out. Here is my solution <?php $categories = get_the_category(); $category_id = $categories[0]->cat_ID; $mymain_query = new WP_Query( array( ‘cat’ => $category_id,’posts_per_page’ => ’10’ ) ); while($mymain_query->have_posts()) : $mymain_query->the_post(); ?> //shortened code below <div class=”blog-post”> <h5><?php the_title(); ?></h5> <p><?php the_content(): ?></p> </div> <?php endwhile; ?> <?php wp_reset_postdata(); // reset the query ?>

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)