You may use $_GET parameter to get the id.
$id = $_GET['id'];
Or try this:
global $post;
echo $post->ID;
But it seems you have a problem in the args array. when you know the exact id of requested post you don’t need to use it like that. you can use this instead:
get_post($id);
And then you do not need to loop through because you have one post to show.
Related Posts:
- How do I change/modify the_post_thumbnail(); html output?
- Why would a GET variable one one page of a site cause a 404 error when a GET variable works on another page of a site?
- Where should I install a PHP library into WordPress so that code in a webpage can activate it?
- Why can I not use setup_postdata($post) in the sidebar?
- Correct way to make static pages editable in wordpress
- Multiple pages on one with different HTML
- Is it ok to replace php code with html?
- Add custom HTML to posts page
- Minify HTML, CSS, JS with PHPWee?
- How do I output a database option that is an array into a get_posts array?
- Header has extra HTML block at top before my code
- Add HTML Attributes To Anchor Tags In `wp_list_categories()` Function
- How to only show page id as body class?
- Shortcode content output but not in correct place
- How to properly insert a link to a template in WordPress?
- Show post in slider
- Add a class to the anchor tag on HTML5 gallery
- how to remove metadata from the posts of my blog?
- Logged in user ID as post ID
- How to store data from multiple forms using ajax and php
- Use DOMDocument with ob_start breaks my HTML code
- selected option if current category is the value
- Input data from email form not going to JSON file
- Different post styles depending on category
- How do I remove the product thumbnail link from a specific div in Woocommerce? [closed]
- Query if audio attachment AND/OR custom field
- Show latest posts in a plain HTML website custom widget [closed]
- Is this spyware on my site or a real Java update?
- PHP Syntax Error on get_posts
- Search WordPress using static html page
- Hide HTML element (by class or ID) with PHP
- WordPress plug-in for dynamic download link?
- How to remove the h6 tag for the entry-category Class
- Override user-edit.php to design own profile page
- Where can I find the inline-css of my theme header?
- Make textarea required. Help [closed]
- Menu Custom Data Attributes
- How to get image from url from the database?
- Highlight the links without using dropdown
- How to turn each phone number within the $content to a telephone link?
- Creating custom page template from existing PHP site
- wordpress site – using custom database and PHP
- How do I access post_meta key with php?
- Separate array output into a
- Website completely messes up when logging out
- Calling PHP Titles inside Javascript Markup
- How can I use custom menus with a Bootstrap WordPress theme?
- Remove in post content
- Adding attribute to the post.php form tag in wp-admin
- Using php inside javascript [closed]
- Replacing WordPress Icons (menu,icons32, etc)?
- WordPress custom post type and taxonomy
- Search AJAX Filters – Multiple Query Loops Into One Loop (Optimization)
- search.php to search only the post title
- How to get woocommerce orders with get_posts method in a shortcode
- Display WordPress search results based on the selected Sub-Category
- HTML Form Question
- How do I call a value from the datase using ajax
- Hide A Class and Add Custom HTML Code Using WordPress
- Fatal error login WordPress [duplicate]
- How to use data URL in WordPress?
- Help me I cannot link my font-awesome to my WordPress Theme. I have my font-awesome folder already in my project
- How to use wp_ajax_set_post_thumbnail?
- Passing a value from an input field to a php function in WordPress?
- Comparison operator != not working in field [closed]
- Problem with my Login Plugin
- How to return html as a string from php for WordPress
- Show subcategory name selected in specific category woocoommerce
- Make a full-width wordpress page
- Display child-page links in sidebar on both Parent Pages AND Child Pages
- Unable to insert current username into custom table through html form
- How to display post_content from database in different on template page?
- Splitting table data to pages with numbers
- how to remove replicating a tag inside loop?
- Add Alt attribute to image served with php
- How to add thumbnails from recent posts to owl-carousel in wordpress automatically?
- Create a hierarchical loop at predefined markup requirements
- offset and max_num_pages in pagination gallery
- Even with PHP plugin get_posts not working in widget area
- nested divs, classes for a grid in loop [duplicate]
- featured post as div background
- Trying to customize wordpress drop down categories
- how to manipulate HTML parameters using PHP conditions
- Display wordpress post to static website in the footer
- Php echo into tag
- Parse error: syntax error, unexpected ‘echo’ (T_ECHO) in C:\xampp\htdocs\AttendanceSystem\resources\php\method.php on line 250 [closed]
- How to edit homepage in WordPress?
- Load Meta box value into div AJAX [duplicate]
- WP_Query not returning results
- How do I link the side images?
- Is there a better way to output HTML as a shortcode?
- How to create a container in php then customise it in CSS
- Load wp_editor on button click
- Find owner of coupon
- Add topbar to static html page
- ‘This Field is Required.’ is Not Displaying on CF7 [closed]
- Why do I get a 404 error on my custom post type archive pagination?
- change div text and link for logged in users
- Font Awesome Icons as squares [closed]
- How to modify default tags in wp_head()