There is a function called url_to_postid
$id = url_to_postid( get_permalink(40) ); // $id will be 40
Actually (WP 3.6) it works only for standard posts and page, but with WP 3.7 it will also work for custom post types.
Related Posts:
- How do I make a redirect in PHP?
- WordPress and event-driven programming – what is it about?
- How WordPress encrypt password? [duplicate]
- Retrieve POST data from AJAX call
- Adding a custom image upload size and making it selected by default?
- Display all meta for a post?
- How to include external page to wordpress page?
- Facebook Comment Count
- Conditionally loading JavaScript based on the Advanced Custom Fields in the post
- How to overwrite youtube embed?
- How to resize image on client-side before upload?
- Filter the blog title displayed in the header
- Print html when custom field has value inside while loop
- Foreach insert query the best way
- Stop Duplicating Terms in a Foreach Loop
- Generating add_settings_section() calls dynamically
- How to generate page content from database the right way?
- How do I show the featured images for my child pages on my parent pages?
- Register non hierarchical taxonomy and the show meta box in the post type
- Admin username and password
- dynamic php inside wordpress page
- Converting MYSQL to WordPress $WPDB
- WP_Query loop, does not display special characters in title correctly
- Random Default Avatar Function
- Get Admin Email Address From External PHP page
- Redirect to another page after submission using wp_mail
- How do I get current page ID in WordPress customizer file?
- How to run a php file that uses wordpress functions from command line?
- Loop with slider (slider not loading)
- wordpress media library new uploads don’t write to database
- Add data attribute to each li in menu
- Was told to change the .htacess file form .html to .php so this would work properly
- WordPress Ignoring .user.ini
- Cron events are disappearing, or cannot be updated in WordPress
- How to bypass maintenance mode with external cron?
- Displaying Woocommerce Product Category in WordPress
- Split reads to a different connection string
- custom user role wordpress – grant guest access to edit.php without insert/update/delete
- PHP > Scheduled Tasks > Sending daily email with dynamic API variables
- “Undefined index” error when saving empty array with checkboxes
- HTML escaping data with ajax requests
- Custom ajax call returns 0 [duplicate]
- Metabox Not saving data
- 2nd page displaying the exact same posts as my first page (minus the very first post)
- Timthumb.php image gallery not working on Multisite WordPress
- Parse error: syntax error, unexpected ‘,’
- Use get() method to grab all categories and output inside another method
- get_the_ID() doesnt work
- How to set cookies
- How can I split my query result in 2 arrays?
- Manually Create PHP Page For A Redirect
- How do I check if there is a tag in the title
- GravityForms Limit Submission Per Time Period by User or IP by 30 minutes?
- Get All In One SEO Pack to use custom field instead of Content
- php loading different structure than source code
- Truncate title to single line & container width
- Submit form to db
- WordPress Rewrite Rule
- How do I attach an invoice PDF to an email in the Dukapress plugin for WordPress?
- Programmatically revert to backup .htaccess a possibility?
- Prevent post from being published and show error
- how to get wordpress page url php code [duplicate]
- WordPress User Meta value variable into Google Gauge Chart
- Problems updating nested ACF field groups
- how to pull all usernames from a custom user role, then do some array modification
- Unable to delete related media attachments with deleted post
- Submiting with problems on one of the options php wprdpress
- Embed video from streamtape using direct link
- separate list of programs in html/javascript coming from php
- Is there a PHP function that will return the block ID generated by WordPress?
- str_replace remove words from title
- Woocommerce checkout page – custom field checkbox value into email
- How to print all the inline styles in the WP_Styles instance together with their keys?
- Issues adding Recaptcha v3 to WordPress Registration
- Create form which redirects to site in network?
- Theme editing “post thumbnail” help
- Hide comment notification number and buttons in wp backend
- Create html tree sitemap
- Restrict File Type Uploads by User on Wordress via functions.php
- How to Request a User to Register on Landing at a Site, Then Automatically Delete the Users Password on Logout?
- meta field for numerous links
- Custom HTML form using PHP – help with ajax/username validation
- AJAX Returning Way Too Many Posts
- WordPress AJAX load post metadata in modal
- Add point on excerpt post
- Custom Theme, Editor won’t wrap text (i.e. change width)
- Where can I find the declaration of `$_wp_theme_features`?
- add shortcode heading showing multiple time
- How I can add div to menu?
- How to print redirected query string variables to the page?
- Limit ads appearing more than three times
- Multiple URL from Custom post name
- Admin-area broken through weird issues
- Get string from array and start loop [closed]
- Custom query_posts() parameter
- Convert ACF checkbox choices to links [closed]
- How to modify this function to exclude also the post belonging to a specific category?
- wp_link_pages return value even when is condition inside if statement
- Pull latest Youtube Video from json url and make new post
- PHP $_SESSION array – only showing current index