As you are on, ‘single-press.php’ , this is single ‘press’ post type page. As per your question, it seems you want to display archive of all ‘press’ posts, along with current posts highlighted.
As we are on single ‘press’ post page, no need to check for post type.
We can directly add following loop with modification in structure, as per your need,
global $post;
$post_args = array(
'post_type' => 'press',
'post_status' => 'publish'
);
$press_posts = get_posts($post_args);
if(!empty($press_posts)){
foreach($pres_posts as $single_post){
?>
<a href="https://wordpress.stackexchange.com/questions/162905/<?php echo get_permalink($post_id); ?>" class="<?php if($single_post->ID == $post->ID ) echo 'wdm-current-post'; ?>"><?php echo $single_post->post_title; ?></a><?php
}
}
So now we have given a class ‘wdm-current-post’ to the current post. All the posts will now be listed with the current post highlighted in the list.
Related Posts:
- How to get post content by calling ajax?
- Get the ID of the latest post
- How to get all children and grandchildren of a hierarchical custom post type?
- Getting the Intersection of Two Custom Taxonomy Terms for a Custom Post Type?
- List most recent image uploads, but only for specific custom post type
- Get all authors with at least one post of ‘custom post type’
- Show the First Post from Each of 3 Different Post Types on a Web Page?
- functions.php conditional tag only for custom post type
- Retrieving 3 latest post from each of 5 different custom post types
- custom post type upcoming post and past post
- How to get only one category of custom post type?
- post__in not taking my list of IDs
- How to query custom post type by term?
- Getting a custom post type image using ‘get_post_custom’
- Get random custom posts from a custom post type
- Quickest way to get last or oldest post date – WP Query
- Filter the content from a post globally immediately after is fetched from the database
- Combine query_posts() and get_posts() into single query
- Are there sub-systems in WordPress that would employ data structures beyond CPT that a `get_posts` won’t be able to catch?
- Shortcode for display posts on home page show only one post
- WordPress count child posts of each parent custom post type and use in json array for google maps jquery plugin
- How inefficient is it to use a Custom Post for 4-5 sentences & pull all to 1 page?
- Display content based on a users login
- Stuck in Order by more then one
- Query Multiple Custom Posts by Custom Fields
- Multiple (two) category postings on the same page.
- ‘exclude’ argument is not working with get_posts for a custom post type
- How to get the intersection of two terms both from different custom taxonomies
- Display latest x posts from all categories in Custom Post Type/Taxonomy
- Reworking function for counting custom post type posts count
- Get only used meta_values
- Number of posts in the archive
- Custom query for custom post_type
- Recoverable Fatal Error – Object of class WP_Post could not be converted to string
- populate array with posts
- How to Make infinite loop of post
- get_posts seems to be skipping the last Post
- Displaying multiple post types on home page
- Conflict between wp_list_pages and get_posts – list pages not displaying
- Return number of all custom posts type by author in all statuses
- Is it possible to use array_walk() to append terms to an array of posts?
- custom hierarchical taxonomy and custom post type list contains surplus posts
- Group by custom field value (start and end times)
- meta query not retrieving posts
- How to get custom post type title, excerpt, thumbnail and permalink by post ID?
- Get posts by category name
- Why the_excerpt() function returns excerpt on the Home page and trimmed content in sidebar?
- How to properly use Categories with Custom Post Types
- Can’t pull posts of a Custom Post Type based on the custom taxonomy of the CPT
- 4 posts per page from single category
- Query custom posts of logged in user only
- Display a random customposttype2 excerpt in single-custompostype1.php that shares same taxonomy
- Getting the list of the latests posts and custom type posts in the homepage
- How to query custom post types with multiple keys?
- date_query empty results with custom post type
- Orderby meta_key/meta_value not displaying anything, am I overlooking anything?
- get_posts() returns empty on custom post type /wp-admin/edit.php
- Get_post_custom not fetching value from array wordpress
- I’m having trouble with Related Product “tax_query” ‘terms’ value
- Custom post type data not displaying If I select the category from the dropdonw
- get_posts wont produce a list of custom type from a given category [duplicate]
- Limiting the Number of User Posts to Their Own Posts
- Get all posts by many custom post types
- Modify default Related Posts Code to Custom Post Type
- Query a custom taxonomy in a function to create an csv file
- week days sorting based on starting day
- Query posts based on user preferences
- Error get_posts with Custom Taxonomy and OR relation
- Why get_posts() returns empty array while I am trying to get posts from some specific taxonomies and work properly with others?
- Get post from Category by Priority
- How can you use a page for a custom post type?
- Running get_posts within get_posts to get children of children
- WordPress get all post with like in terms [duplicate]
- Certain number of posts with certain excerpt length
- Decrement term in for each
- Help ordering custom query by Title, Ascending
- This wp_query will not return any posts and only seems to work with post_status inherit?
- Popup panel is only displaying 1 entry ignoring all others
- Fetch posts list from fist CPT taxonomy term and list under 2. CPT
- one get_posts to return a number of custom posts for each meta value
- How to create content automatically when a post is published?
- Query posts by a type and another type only if post is in specific category
- How can I give WordPress child custom post type the same title and slug as its parent?
- Custom Post Type children and grand-children in one list
- shortcode for recent custom type post
- How do I display the index position of a post from a custom post type?
- How do I correctly query posts from a post ID?
- Custom Post Type meta value is being saved in array, instead of just the string (as value)
- Display posts from another page on home page in wp-editor
- show custom post’s post in two different divs [duplicate]
- Add Category names to post lists of custom post type
- How to I add count of custom posts listed in a post as a prefix to its title
- How to get permalink of post based on post name?
- Create a hierarchical list of posts that’s grouped and nested by category
- How can I show a field ID in Elementor with Request Parameter
- post__in select all custom posts and not the selected array of ids
- Do attachments added to custom post types have a post parent?
- How to Set Post Status to Draft if older than today
- Create a post in custom post type using field in registration form after users submit form
- Displaying custom taxonomy in the admin list of a custom post type