It looks like you currently have a WP_Query (or similar) setup that excludes the current post by using 'post__not_in' => array( $current_post_id ). That means it won't show the current post but will show other posts.
If you want to show only the current post instead of other posts, you need to modify your query arguments so that it includes only the current post. That means:
Instead of excluding the current post (post__not_in), you want to include only that post using post__in.
User
excellent! but this is for singular wpsl_stores, how can i show all posts in the homepage?
Assistant
Great! Since you want to:
On : show (which you already have working).
g
s
=
array(′posttype′=
>′
wpslstores′,′poststatus′=
>′
publish′,′postsperpage′=>
Set 'posts_per_page' => 1 since you're only showing one post.
Make sure $current_post_id is set correctly.
Here's how you can change your code:
if ( is_singular( 'wpsl_stores' ) ) {
$current_post_id = get_the_ID();
$args = array(
'post_type' => 'wpsl_stores',
'post_status' => 'publish',
'posts_per_page' => 1,
'post__in' => array( $current_post_id ), // Include only current post
'orderby' => 'title',
'order' => 'ASC',
);
}
Explanation:
post__in restricts the query to only the post IDs in the array you pass – in this case, only the current post ID.
posts_per_page is set to 1, so only the current post is shown.
Removed 'post__not_in' because you're no longer excluding the current post.
Note: If this is inside a template on a singular post (e.g. single-wpsl_stores.php), you most likely don’t even need to run a query to fetch the current post again—the_post() loop will be available. Only run a query if you need a custom loop or special data.
If you were trying to show ONLY the current post but within a secondary query for some reason, the above is the correct way. Otherwise, to display the current post in single post template files, you can just rely on the default loop without additional queries.
singular 'wpsl_stores' posts
only the current post
On the homepage: show all 'wpsl_stores' posts (or some subset or all your posts, depending on your needs).
You can do this by conditionally building your query arguments depending on the context.
Example:
if ( is_singular( 'wpsl_stores' ) ) {
// On single store page: show only current post
$current_post_id = get_the_ID();
$args = array(
'post_type' => 'wpsl_stores',
'post_status' => 'publish',
'posts_per_page' => 1,
'post__in' => array( $current_post_id ),
'orderby' => 'title',
'order' => 'ASC',
);
} elseif ( is_front_page() || is_home() ) {
// On homepage: show all wpsl_stores posts (or as many as you want)
$args = array(
'post_type' => 'wpsl_stores',
'post_status' => 'publish',
'posts_per_page' => -1, // -1 means all posts (be careful with performance!)
'orderby' => 'title',
'order' => 'ASC',
);
} else {
// For other pages or archives — customize as needed or leave empty
$args = array(
'post_type' => 'wpsl_stores',
'post_status' => 'publish',
'posts_per_page' => $post_count, // your default number or whatever you want
'orderby' => 'title',
'order' => 'ASC',
);
}
Notes:
is_front_page() is true when the homepage is the static page set in Settings > Reading.
is_home() is true when the homepage shows the blog posts index.
Use either or both depending on your setup.
Using 'posts_per_page' => -1 loads all posts — useful if you want to show every post. If you have hundreds or thousands, consider pagination or limiting the number for performance.
Make sure you use $args to instantiate your WP_Query or however you are using the arguments afterward.
Example of running the query:
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
while( $query->have_posts() ) {
$query->the_post();
// Your code to output the post information, e.g.
the_title('<h2>','</h2>');
the_content();
}
wp_reset_postdata();
} else {
echo 'No stores found.';
}
Let me know if you'd like help integrating this into your template or for pagination too!