<?php
$related = get_posts( array( 'category__in' => wp_get_post_categories($post->ID), 'numberposts' => 5,'post_type' => 'news', 'post__not_in' => array($post->ID) ) );
if( $related ) foreach( $related as $post ) {
setup_postdata($post); ?>
<li>
<?php the_post_thumbnail(); ?>
<a href="https://wordpress.stackexchange.com/questions/151897/<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</li>
<?php }
wp_reset_postdata(); ?>
Related Posts:
- Use post in multiple places on a page with multiple posts
- Only show current category post
- How to show all posts of the category in wordpress?
- Get category id from post id of a custom post type
- how do I group content in magazine-style ‘issues’?
- Newer/Older posts links display same posts on every page
- How do I write this SQL statement for Posts written in last 24 hours?
- Structuring a product catalogue in WordPress [closed]
- How to create posts (not post template) to be displayed on projects page?
- Query Custom Post by Category
- IF statement in a do_shortcode
- Display types of posts in edit.php instead of All, Published, Scheduled and Draft
- Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?
- get_template_part for custom post type content not working
- Loop on front-page.php
- Custom Taxonomy – Tags Metabox is showing instead of Categories
- How to get all posts except for one post from a certain custom post type?
- How to get the post type from a category id?
- How i can add ‘N’ page of ‘N’ pages under posts loop?
- Getting posts under the custom post type ui category
- Show custom post type filtered by category
- I would like to have different styles for my posts based on the content of each post
- Showing posts from different categories and from custom post type
- List custom taxonomy specific to one custom post type
- Show a Category X’s custom post type on Category X archive page?
- Add custom post type settings to wordress default posts
- Problem with displaying posts in the CPT category
- Custom post type, organized by categories
- Set a checkmark in a category based on a URL-parameter
- WP Query with categories only shows one post and ignores the category
- Get the category from custom post type
- Custom Post Slug same as Parents Category Slug
- Shortcode not working with post counter
- How can I show 1 featured post in a styled element, and the next few below differently styled
- Custom Post Type Category Link
- Custom Post type category pages template and loop
- WP the_posts() on single-cars.php get category link
- Conditional for a Single Post That Belongs to a Category?
- Create new custom post and post category of same name
- Tag page only display 10 posts
- Custom post types and ‘new WP_Query’
- How to Display Posts From Category Within a Custom Taxonomy?
- Showing custom post type categories in the menu
- How to Make infinite loop of post
- WP_Query with custom post type ID
- Stores category posts in an array
- display posts of custom post type with custom taxonomy
- Restrict category access to specific users/groups. Author always has access
- Get post format
- Custom wordpress loop
- Post Query not working
- displaying content of custom post type
- Posts are not rendering perfectly [closed]
- get_terms() parent, child and grandchild
- Display post from custom post type
- The loop does not show users
- How to fetch posts that are stored in the different table than (default) wp_posts?
- Am I mixing up the concept of posts pages and categories?
- CPT archive page – show one post from each taxonomy term
- If/Else child list for Custom Post Type single template within loop?
- Show the categories the current post has
- Display all Categories except ones with a specific parent
- What is the best way to set the post category (Custom Post Type) automatically based on the one of the tags assigned to the post?
- Post category behave like a Post in back office menu
- Save data is post using php front end
- SEARCH QUERIES – REVERSE OUTPUT
- Custom WordPress theme not displaying posts from category
- How to show posts of the same category on a page?
- Pagination for a cpt filtered with a category
- How can I group by Taxonomy on Custom Post Type while filtering out based on custom Meta
- subtracting the current post form then whole loop, which is generating all CPT titles
- How to manage a dynamic multi-level page hierearchy system?
- Custom Post By Category
- Display title of all custom posts from same taxonomy term on a custom post template
- Custom post Query and WordPress Post Query Clash
- Change Custom Post Type to Post + Category
- Excluding category from loop not working
- Custom post types not displaying per category
- How To Loop Through list with Custom Post Types
- Custom Post Type + Category archive
- How to query all custom posts of a certain type and checking what category they have
- Post Editor: display categories from current post type taxonomy only?
- Custom Post Type used for FAQs Accordion
- How to create content automatically when a post is published?
- Display all post types together
- Turn post into simple slideshow
- Pulling in a particular post into a single page based on the post id passed into the code
- Categories and page filtering with pre_get_posts
- Styling first post using Advanced Custom Fields
- the_content() stop images being pulled through
- show only one category posts in admin
- display all posts in current category
- Can WordPress show posts based on a button that the user clicked 2 pages back?
- Alphabetical sorting of custom post type – one letter per page
- next_post_link and previous_post_link in custom post type single page, in same non-custom category
- How can i create an custom post template for an specific post category? [closed]
- Modify previous and next post links to current Authors Other posts
- Invalid Taxonomy
- can’t see categories in appearance-menu-categories
- show posts under custom post type with same autj