Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Replace content in WordPress Page after GET from php page

Reread your question and revised the solution as well. It is a Page template now and should be set to the page that needs its content protected. It relies on a “login” post that has the html from.

<?php
/*
Template Name: Protected Page
*/


// Standard HTML of Theme

    global $post;

    // check if authentication has been made
    if( verifyAuthentication($_POST['authCode']) ) {

        // display protected content
        the_content();
    }       
    else {

        // fetch the login form html from "login" post. Or you can read from a file or some admin settings of your plugin.
        $login_post = get_post( url_to_postid("login") );

        // display the html form
        echo apply_filters('the_content',$login_post->post_content );
    }


// Standard HTML of Theme

Post parameter authCode is supposed to be present and valid when login has been successfully authenticated.

Related Posts:

  1. Getting only direct child pages in WordPress with get_pages
  2. Disable Attachment Pages Completely
  3. How to add a .php file to WordPress
  4. How to Remove all Instances of edit_post_link
  5. Is having multiple theme customizers for different pages possible?
  6. How to check if feed URL was requested?
  7. Create WordPress pages with PHP
  8. Is it possible to generate a page without create in the admin?
  9. WordPress admin never finishes saving page on site with large page count
  10. class=”parent” for wp_list_pages?
  11. Check if Favicon is set in Customizer
  12. PHP Script within wordpress theme
  13. Dynamically loaded Theme components based on Customizer Settings values : changes not appearing in Customizer preview – (Workaround found)
  14. Listing all sub-pages?
  15. Customizer Show/Hide Logo and Site Title
  16. WordPress Customizer not setting default value upon initial install?
  17. How to get custom image size for image uploaded in Customizer
  18. Help with a custom page template – listing contents of childpages?
  19. Print number of post (in reverse)
  20. Crop image from get_theme_mod Customizer field
  21. Get/Set wp.customize.previewer.previewUrl
  22. How can the plugin directory path be returned into ?
  23. Add a Different CSS Class Into The Body Tag of Different WP Pages
  24. Limit get_pages to only show 5 items
  25. syntax issue on php 7.4
  26. How do I publish only one page to production after making changes on staging?
  27. Custom Template 404 for specific custom post type
  28. Can’t load WP function into external function
  29. Difference between ‘type’ => ‘text’ and WP_Customize_Control
  30. Insert a button on a page with random number generation
  31. How do I get current page ID in WordPress customizer file?
  32. Count top level menu items
  33. Global variable $post returning incorrect object
  34. Customizer – Prefix Class Extension
  35. From where the header-text can be changed in WordPress custom header?
  36. Sort query_posts for Parent Pages to menue order or the count?
  37. Return a numerical function value in Customizer controls
  38. My page.php shows the index.php
  39. How do I find PHP file that contains content of my page?
  40. WordPress page content outside WordPress
  41. Inject class in body when particular page template is used
  42. Use .php file as page instead of wordpress page & template file?
  43. Use WordPress function in php file
  44. How to check if the current page is at a specified path in the URL?
  45. How to check if a Customizer setting is set?
  46. What’s the best way to include PHP code in pages?
  47. Automatically add images to a menu
  48. page-slug.php not working but only for specific slug
  49. Need php code’s output to display underneath a Divi Module
  50. Extending WP_Customize_Media_Control to return filename
  51. Please show me how to use an if/else statement in combination with wp_enqueue
  52. How Do I Find & Remove H1 From Site-Title-Wrapper? [closed]
  53. Display child page content of a specific parent on home page
  54. PHP Output also in Child theme, but different
  55. Use SCSSPHP to compile Theme Customizer Values into .SCSS files ready to compile to CSS
  56. Unique PHP on each Page
  57. How to Display a List of Child Pages For a Parent Page in WordPress
  58. If is page, archive or search output this code
  59. WordPress Search
  60. How do I add my PHP app to a WordPress page whilst keeping semantic URLs?
  61. Page load timer?
  62. Getting text from custom field from customizer
  63. Page not visible in ‘All pages’ after being added through PHP
  64. Grabing default from cuztomizer php file instead of other php script
  65. Cascading dropdown select search based on Parent Page & Child Page
  66. Edit and delete permissions pages and posts
  67. Illegal string offset in PHP function in via Theme Customizer
  68. A function to get the content of a page
  69. When I click for the redirect link it is showing the content of index.php instead of single_assignment_page.php
  70. Category Page Displaying all Pages
  71. How can I edit a php custom page template to work in other themes?
  72. Display page content in different sections – based on page break block?
  73. Change CSS Variable value in Theme Customizer Live Preview
  74. Child and Parent Pages list of sub pages
  75. Customizer: How to Sanitize a Decimal Number Range
  76. How to update option field in database on clicking the publish button in customizer
  77. Use page-templates without creating theme
  78. Get current_post in reverse order with pagination
  79. Multiple sections in Theme Customizer overwritten
  80. Sort on two variables
  81. Using get_theme_mod with checkbox to display content
  82. Create a custom theme-specific page, invisible in the admin-panel?
  83. Create Customization Controls from Array
  84. Execute php in pages
  85. Why isn’t my link attribute getting my css?
  86. How to map my php files as the files for pages
  87. Show results for multiple page-types
  88. How to add feature image url in my template file and content as well?
  89. Display selected parts from selected pages on the frontpage?
  90. How to add button to top of theme customizer?
  91. Adding Media button to only pages
  92. How to refresh a template page on WordPress in 3 seconds – easiest method?
  93. How to handle parent and child pages?
  94. How do I remove blog entries from home page Twenty Eleven child theme?
  95. How to store the_post_thumbnail() value in a variable
  96. PHP warning $post->ID is null
  97. Capture the Selected Radio Button Value between two files in wordpress theme
  98. WordPress Customizer – How to save list of checkbox of pages?
  99. Show the terms of the hierarchical taxonomy
  100. Custom theme on multisite has issues with standard loop output
Categories PHP Tags pages, php, remote-login, theme-customizer
Custom Post Status & Taxonomies
custom login form, guide me

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress