If I have understood correctly, you could use get_the_ID() and compare the value with get_queried_object_id() to archive this:
$args = array( 'post_type'=> 'portfolio', 'posts_per_page' =>100, 'offset'=> 0 );
$myposts = get_posts( $args );
$current_id = get_queried_object_id();
foreach ( $myposts as $post ) {
setup_postdata( $post );
printf(
'<option%s>%s</option>',
( $current_id == get_the_ID() ) ? ' selected="selected"' : '',
get_the_title()
);
}
Related Posts:
- Export posts manually selected by end user (not logged in)
- How to populate a select field with post titles/ids in a block
- Custom Select Query pagination not working properly
- Add category selection to function request
- Get post title by Alphabet
- ZIP up all images displayed in a [gallery] and offer as download link
- Random sort within an already sorted query
- How to validate XML-RPC post creation and cancel when needed?
- the_author() returns empty string
- Custom Field in Featured image for A particular post
- Custom permalink structure only for default posts
- List latest posts in WP-Admin
- Email admin when post pending?
- WordPress Number of Posts Not Changing With posts_per_page
- Adding a Nav menu to post admin
- Comments enabled, but disabled at the same time
- Mass Update lines of code for all posts
- set role specific screen options in post summary page
- How to get a nofication when post submitted
- How to link up “read more” on excerpts hack from WP Recipies
- Post preview and oembed provider issue using polylang plugin with subdomains
- Any idea why wp_insert_post is succeeding but not returning?
- How would I get 1 latest post from a query for 5 posts?
- How can I link a CSS file only on single posts?
- add_action not using ‘delete_post’ action with wp_delete_post
- Getting post id from wp_insert_post_data function?
- get custom image size
- Does an article (post) id ever change?
- Lazy Load using WP_Query pagination
- Is there any way to allow users to access content before it’s published?
- Get Posts via Taxonomy Term Name with Space
- Display posts in three columns by category
- Change post_date to post_modified date on post template?
- Update Post creation date when updated
- Duplicating Table of Contents for Paginated Post
- Deleted category by mistake, all posts now have categorized category. Can i revert that?
- Query how many items to show in shortcode
- Removing rel=”nofollow” from links posted in Post Content
- Delete post by giving its link
- wp_insert_posts add title with count of posts plus one
- How to make classes for posts?
- Relative redirects for posts, categories, products and product categories
- How could I change my Permalink from blog to custom structure? [closed]
- WP Admin register taxonomy and post type performance
- How to make multiple sections in home pulling posts category wise?
- If statement to check if post has image
- What file is the standard frontpage that lists all the posts?
- Is there any upper limit for the number of posts that can be created with wordpress
- Automatically create a default set of posts for each new registered user
- why the same code got different results when using query_posts in functions.php and index.php
- Possible to add a statement to a core file?
- WP_Query: Show 10 posts in date order, first three random
- get_children returns older images
- Exclude post category in a blog page
- Banner appearing on Pages but not Posts; call it conditional confusion
- how do I get the title in the post [closed]
- Publish a Silent Post without updating Feed
- Get a post’s ID
- How to make posts being uncategorized
- How to display a single(current) post from a category
- Delete post from admin but not from database
- how can display a post on home screen without images
- Custom Select Query – Selecting the Year?
- how to create a sub section in posts
- Filter out posts based on a certain post_meta on the WordPress REST API
- WordPress Query – Display 5 posts (same post type), each from a given tag
- Edit post & page option does not display on latest wordpress
- Separate top level categories on archive-product.php by meta
- How to add text before post_excerpt in Gutenberg
- Permalink Short code showing unnecessary link text inside the loop
- Pinterest button shows image options from different posts
- allow user to create a draft post but not publish wordpress
- Comments are in database, don’t show up in WordPress backend or frontend
- Show code only on WooCommerce Pages
- WP_Query that targets all categories
- Prevent WordPress from putting around specific element
- How to put the WordPress blog into theme
- How to correctly escape data
- single- and archive- templates not being applied to custom post types, not even after flushing permalinks
- Sort Events by Venue Title – Sort Post set by related post ids
- Posts per page, reverse count
- Get posts by category or author
- get_the_ID() fails the first time, returns a value the second time it’s called
- I moved my site to another server, wp admin works so does the front page, but posts don’t work
- How can I have the posts from one word press blog show on the presentation page of another word press site
- How to Test a Blog Post for Update vs. Publish Status — Unique
- How to pass multiple checkbox values to wordpress query?
- How to get all the terms of a post
- How to create three columns from selected posts
- Columns in a “post”
- Display the popular tags by default in the backend post edit page (without having to click on the link that displays them) [closed]
- Getting 404 when using rewrite rule for posts
- Posts and pages not getting published
- how to show all post with its contents
- Cannot Create a new Post [closed]
- Last updated post in wordpress homepage first position
- How to make category for word post_content
- How does WordPress add the comments and comment form to posts
- website images getting corrupt automatically
- Posts Page in WordPress loading bare HTML of my homepage