get_page_by_path()
should help you here. Something like this
<php
$prev_url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
if ( $prev_url ) {
$prev_path = str_replace( home_url(), '', $prev_url );
$page = get_page_by_path( $prev_path );
}
That should give you the page object, where you can access it’s ID like so – $page->ID
.
Related Posts:
- how to get page id of a page using page slug
- How to retrieve the content (with a specific ID) via ajax by clicking a link tag
- Passing the page ID to a login php script
- get_users(…) only returns one user
- Open post-content in archive page in a Modal box with bootstrap
- Making (and edit existing) posts with ID included
- get_the_ID() in the footer returns wrong value
- Use post ID in functions.php file adminside
- echo esc_url( get_permalink($post->ID) + complete the ID’s url
- create front-end users post list by specific category
- php return username of currently viewed author profile
- Give ID to divs inside the loop
- How to block specific user id in custom login form?
- Get current user id in function php
- Trying to get post ID outside loop on blog page
- Trying to get property ‘ID’ and ‘post_author’ of non-object error
- How to get the url of the entry in which an image belongs
- main menu page redirects to user ID
- How to add a .php file to WordPress
- When to use Exceptions vs Error Objects vs just plain false/null
- Woocommerce get selected shipping zone id for the current user
- Include files in functions.php
- Display all meta for a post?
- Is there a reason why my wordpress PHP page isn’t loading into my PHP template
- Add to previous posts under post
- How to show order data by multiple ID?
- Print html when custom field has value inside while loop
- how to create and show sessions in word press?
- Categories Template Assistance
- Stop Duplicating Terms in a Foreach Loop
- Generating add_settings_section() calls dynamically
- How to trash multiple post/product programmatically
- Loading jQuery in the footer after removing jQuery migrate?
- Proper way to edit a post via phpMyAdmin without breaking the compare revisions tool
- Sending jsPDF documents to the server
- Unit Test in WordPress
- “before delete post” action fire when the post is updated?
- Register non hierarchical taxonomy and the show meta box in the post type
- Admin username and password
- WordPress excerpt not working
- Random Default Avatar Function
- Custom Text in WooCommerce Order Processing Email Based on Products
- Loop with slider (slider not loading)
- How to set up VS Code for WP plugin/theme development in 2021? [closed]
- Error when adding excerpt to the content through functions.php
- Fresh Install WP error – “The site is experiencing technical difficulties” [closed]
- Woocommerce : Can’t get product info in loop
- inserting a post from an extern php file but post content doesn’t show on wp site
- Way to add captions to gallery images by code
- Echo possibly causing custom template formatting conflict
- proper way to add css using functions.php?
- How do I create my own .php file with a code part and echo it on different pages?
- “Undefined index” error when saving empty array with checkboxes
- Custom ajax call returns 0 [duplicate]
- HTML table attributes ignored
- How can i change variable if condition is not met
- How to use wordpress function wp_enqueue_script() in php?
- Reading settings in the home page precisely home.php
- Create a package of products as one Item in woocommerce?
- Calling function in loop causes repeat data
- How can I include the user id inside of a shortcode php output?
- How to use wp_nav_menu to create custom dropdown menu?
- How to set cookies
- Is there a hack for using is_page() within the function.php file?
- Add a custom class to the body tag using custom fields
- how to edit a specific post slug using a php code?
- Display the video of a post_format Video
- Manually Create PHP Page For A Redirect
- Get All In One SEO Pack to use custom field instead of Content
- Display multi-select box choices in a bullet list [closed]
- the_post(); prints out style text into my HTML?
- How do I attach an invoice PDF to an email in the Dukapress plugin for WordPress?
- Calling code from another plugin to custom profile field
- Require()/Include() post template adding extra content
- Approval by Admin to confirm the change
- couldnt show short code atts in category
- “WARNING: Found @$ in the file __ Possible error suppression is being used
- Changing ALT-tag for logo in wordpress
- str_replace remove words from title
- Help with preg_replace
- Create form which redirects to site in network?
- Advertisement in Loop Posts wordpress
- WooCommerce multiple custom fields code
- How to display last whole post on the homepage
- Custom Plugin Develoment, Form Action
- Restrict File Type Uploads by User on Wordress via functions.php
- Resource 404 error on multisite subdirectory install
- AJAX Returning Way Too Many Posts
- WordPress AJAX load post metadata in modal
- Give permission to admin to see user’s page
- List of child pages fetch next results at link click
- Limit ads appearing more than three times
- How does add_action ‘comment_post’ work?
- Showing Subcategory’s Name and Link Instead of Parent Category’s
- reorder a WP_Query, using a dropdown
- Select area and checkbox data is not saving?
- Suppress errors when using global function
- In reading settings posts are set to “blog” and I have page-blog.php but no posts
- using a shortcode in a hyperlink
- WordPress critical error after trying to update to 6.2 – Fatal error: Allowed memory size of 268435456 bytes exhausted