If you have the post’s ID, I assume that you are the owner of the blog ( Not because others can’t have the ID, but because only the owner should do such tasks ).
To convert the post ID to the post’s URL, you can use get_the_permalink()
:
$url = get_the_permalink( $id );
Afterward, you can use file_get_contents()
to fetch its content, including the full source of that web page. So, your full code will be:
$url = get_the_permalink( $id );
$data = file_get_contents( $url );
Which data is your HTML source. Note that this will only work in the WordPress environment.
Related Posts:
- dealing with large HTML output via plugin code
- How can I make my custom shortcode work in a Custom HTML Widget?
- Output in XHTML or HTML 5 for plugins?
- Editor not displaying dynamically after clicking on the button
- How to add an attribute to the body tag with a plugin?
- How to make a custom field as an editor in wordpress?
- How to trigger $_GET request within admin plugin page?
- How can I get WordPress to save comments in markdown format?
- Images under 1MB are not being compressed
- How to save Setting pages data to the database?
- How to translate to spanish wordpress hardcoded content/files?
- Can’t access 3rd party API, code works on local server but not on wordpress
- Form tries to download a file on submit
- hide load more button if there are no posts left to display
- How to create a “Most Popular” & “Latest” TAB in WordPress
- Getting a List of Categories for Use in a Plugin?
- Changing labels of status filters for post grid
- Can we use a webservice with WordPress?
- Where to call add_shortcode function in WordPress Plugin Boilerplate?
- How do I add a custom sub menu menu under Woo-commerce marketing?
- WooCommerce get_price returning wrong price when used via ajax
- How to ‘clone’ a wp plugin to make small changes
- How to load plugin after page is loaded – pagespeed issues
- Open Post Thumbnail in New Child Theme File in WordPress
- How to pull code snippet from functionality plugin?
- How to use get_theme_mod in gutenberg editor wordpress?
- MITM risk of not sanitizing?
- Get IDs of Images from Gallery Block in InnerBlocks of a Custom Gutenberg Block
- How to keep users unique id stored in session in addition to IP in WordPress plugin?
- Loco Translate: Custom Post and Custom Taxonomy Labels not translated in wp-admin menu
- Where should I save an API key of my user when installing my plugin?
- How to make a customize role and view a specific plugins base on that role?
- Reusable functions and tools (Framework)
- Is Wrapping intval() Around esc_attr() Redundant for Escaping Input?
- Programatically download a plugin
- Error shown for Trying to get property ‘roles’ of non-object in WordPress After Content for User Roles
- WordPress plugin – Error “Plugin generate 2890 characters of unexpected output when activated”
- Hook into and send mail using WP Mail SMTP type plugin from HTML static front page?
- React JSX in WordPress Plugin Development
- My plugin wants to update another plugin
- Redirecting to home page after login as custom role WordPress
- Add keywords meta to index.php page
- Custom form action to handle data inside a plugin
- Where (or when) should I register a new taxonomy?
- Woocommerce plugin for minimum order and add-to-card-step
- Self deactivate plugins after an action occurs
- How to get current post user id
- UnInstallation of a Plugin from a developers perspective – The correct and clean method
- Issue with adding count to “subsubsub” aka quick links on custom_post_type
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- Inserting HTML tag with ACF into shortcode
- How to slice an array using posts_per_page? [closed]
- White page on custom plugin option submit
- Can I use a plugin for a singular page on my website?
- Simple ajax call not working in wordpress plugin
- Plugin version is not showing up in wordpress.org plugin directory
- Do action only on certain front end pages?
- Change plugin main file name (that is currently in the repo)
- Create dynamic page content from custom WordPress plugin page
- Plugin Options Not Saving to Database in WP 4.5
- How to periodically scrape and cache strings from remote txt files. – My First Plugin
- How to create ‘import dummy data’ option in custom wordpress plugin
- Call to a member function have_posts() on a non-object on normal loop
- JS Support Ticket – Auto create WP account
- WP Post Template – Templates in own folder
- Register Page Template from Plugin
- Private Plugin Updates – Localhost
- How to change custom post type pemalink Hierarcy
- Any hook for pre-plugin-update -either bulk or single plugin update
- Get plugin option in another PHP file
- wp_create_nonce function doesn’t work inside a plugin?
- Test files for plugin development
- Input with spaces in Shortcode attributes overwritten by defaults
- Unable to override pluggable function wp_mail
- Avoid class name collision when using third party libraries in plugins?
- How to create custom tables in WordPress using my own plugin?
- New User Form – Custom Menu Page
- Own plugin corrups plugin-activation
- wordpress plugin is not activating from widget
- All Users > User List > Update User Meta Field Inline
- Checking instances of scripts in wp_head
- How to save post change url youtube link?
- Best approach to fetch data from wp options to js file or php file
- Correct way to perform non-cacheable DB query
- Allow users of my plugin to define their own shortcode rather than use mine?
- Is it possible to create Custom Post plug-in?
- uninstall.php file in Plugin to clean DB
- Archive – same title for the first two posts
- Creating a plugin to sanitize comment and the url field before display only
- Edit Yoast SEO breadcrumbs output [closed]
- Creating plugin using simple_html_dom parser?
- Object Oriented Plugin not working
- Does WP identify plugin by plugin name or plugin_basename?
- switched from query_posts to WP_query, not working now?
- Making a plugin only available on the front-end for the logged in super admin
- Create entire wordpress as a github repositery?
- Help With MySQL to WPDB Query Conversion
- When to load auto-login code?
- AJAX search posts and pages
- How to find the origin of a file upload from within wp_handle_upload?