I figured it out.
Before the declaration of $case_query
, I declare the active page id, like so: $active_page = get_the_ID();
. Then, in the while loop after the_post();
I add the following:
$activeclass="";
if (get_the_ID() === $active_page) {
$activeclass="current-page";
}
I also add the $activeclass
to the .case-list-item
div: <div class="case-list-item <?php echo $activeclass; ?>">
Solved.
Related Posts:
- How to get post content by calling ajax?
- How to show all posts of the category in wordpress?
- Get the ID of the latest post
- Pull Two Posts Into Custom Post Type `single-cpt.php`
- Limit the post for differents custom post type in the same wp_query
- How to hook get_terms() to only show count of posts that have custom meta
- Loading post content in FancyBox
- Display “Post 2 of 4” on single post page?
- Query post types with multiple keys
- ascending order custom post type
- posts_nav_link on single post template
- Post Rank on Single Post page based on custom field
- Get all posts WHERE custom_field is LIKE value
- Quickest way to get last or oldest post date – WP Query
- Display only one post each WEEK
- List children on child post
- Get latest 3 posts from multiple CPT in one query
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Limit the post for differents custom post type in the same wp_query
- List all posts in taxonomy term
- Create a post automatically if search result has zero results
- minimize wp_query call to database
- Assign for all post of a post type a specific single-post template
- Use WP pagination functions on a custom page template
- update a posts of other custom post type
- How to get Last post Id of custom post type in wordpress
- query_post causes the posts to be loaded twice on load more posts
- Query Posts From Multiple Post Types
- WP Build-In Post selector for CPT
- How to make a list of posts displaying them 5 by 5 with a “next posts” link?
- Post URL redirecting to homepage
- How can i show multiple post on single post wordpress, just like therichest.com or screenrant.com or hotcars.com.?
- Custom post type not displaying content from single-{custom post type} page
- Order query using custom meta data
- Query Custom posts of same taxonomy as the post itself
- Showing posts from different categories and from custom post type
- Display all posts that were published before full post on single.php
- get custom post type
- Allow non-logged in users to see a future post after clicking on a list of future posts
- Which post does a taxonomy term belongs to?
- custom post type parsed as attachment
- Conditional Query of Custom Post Type and custom taxonomy
- will post_id ever change? Can I safely use post_id for custom queries?
- List custom taxonomy specific to one custom post type
- Show a Category X’s custom post type on Category X archive page?
- Post image in WordPress not appearing on home page
- Custom Post Type Query for Sidebar Doesn’t Work on Front Page
- How to add a custom-post-type post within another custom-post-type post edit screen using AJAX?
- Meta query for custom post type ignored in main query
- Changing custom type name hides the posts
- Display Ad on Specific Categories
- Hiding posts by other users and non-logged in
- Update Post Meta for a logged in user
- Add custom field to Posts and sort by it
- Add custom post type settings to wordress default posts
- Single template showing all posts of that type
- Get related posts of child term of custom post type
- Two Custom Post Types Many to Many Relationship
- Problem with displaying posts in the CPT category
- JS innerhtml changing style when using AJAX
- Show titles, date of all posts on single category page
- Side effects of Script and Iframe in post
- Programmatically rewriting slug through functions.php but returns 404
- How to change the post type a theme shows by default?
- Set a checkmark in a category based on a URL-parameter
- Several post types on WP Query by tag and taxonomy
- No Permission to add new Page, Post or CPT with Admin role
- Update postmeta Parent when post_status child change
- Polylang non-default language ignores tags in WP_Query
- custom post type category count shortcode
- Portfolio Page for Classic Posts
- Add post location with mile radius allowing search
- How to edit this code to get the categories in achieve page?
- Category with post type pagination returns 404
- Get the category from custom post type
- Is it possible to store Custom Post Type data in separate set of tables and still have wp_post class functionality?
- Set up post page like JAMA articles
- Custom Post Slug same as Parents Category Slug
- Shortcode not working with post counter
- Changing default ‘posts’ parameters with register_post_type_args
- Admin Column does not populate with data
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- How to display single post from custom post type loop?
- Setup template_redirect using has_term when NO term assigned
- How to integrate a form (Ninja Form or Contact Form 7) with Custom Post Types?
- Prioritize posts in query by meta keys?
- Query posts based on the meta key values of logged-in users?
- Allow users to create posts without logging in?
- How to get all tags of a custom post type by id
- How to define which register_post_status goes to which register_post_type?
- Load Next Posts With AJAX not working with custom post type
- Different Ways to Query Custom Post Types?
- BBPress Search results in WordPress search
- Custom post type archive page for multiple post types
- 2 Different Custom Post Types in Submenu
- How to assign classes to all elements?
- How can I show 1 featured post in a styled element, and the next few below differently styled
- Listing all term items alphabetically / sorting loop
- Some posts from custom post type to subdomains
- pagination not working for category.php (custom post types in categories)