Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 820517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:29:16+00:00 2026-05-15T02:29:16+00:00

so currently i’m using pods to create some individual pages for a log, filled

  • 0

so currently i’m using pods to create some individual pages for a log, filled with custom stuff.

now i want to use the comments-system for each of this pages e.g.:

mydomain.com/podpages/page1
mydomain.com/podpages/page2
mydomain.com/podpages/page3

this are not pages created with wordpress so simply adding <?php comments_template(); ?> is not working.

any ideas how to solve this problem?
thanks in advance

please leave a comment if something is unclear 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T02:29:16+00:00Added an answer on May 15, 2026 at 2:29 am

    When a comment is stored in the WordPress database, the ID of the post (or page) the comment relates to is also stored.

    Trouble is, you’re trying to save comments using WordPress, but for a page that it doesn’t actually know about.

    So, how about we create a WordPress page for each real page, but merely as a representation, so that your real pages and WordPress have a common ground for working with each other.

    So, the plan here is to;

    • Load WordPress in the background on each of the ‘real’ pages.
    • See if a WordPress page representation already exists for the ‘real’ page
    • If it doesn’t, create it, then and there
    • Trick WordPress into thinking we’re actually viewing the representation
    • Carry on using all of WP’s functions and ‘template tags’ as you would normally

    This code should be somewhere at the beginning of the template file used to render your ‘real’ pages;

    include ('../path/to/wp-load.php');
    
    // remove query string from request
    $request = preg_replace('#\?.*$#', '', $_SERVER['REQUEST_URI']);
    
    // try and get the page name from the URI
    preg_match('#podpages/([a-z0-9_-]+)#', $matches);
    
    if ($matches && isset($matches[1])) {
        $pagename = $matches[1];
    
        // try and find the WP representation page
        $query = new WP_Query(array('pagename' => $pagename));
    
        if (!$query->have_posts()) {
            // no WP page exists yet, so create one
            $id = wp_insert_post(array(
                'post_title' => $pagename,
                'post_type' => 'page',
                'post_status' => 'publish',
                'post_name' => $pagename
            ));
    
            if (!$id)
                do_something(); // something went wrong
        }
    
        // this sets up the main WordPress query
        // from now on, WordPress thinks you're viewing the representation page       
    }
    

    UPDATE

    I can’t believe I was this stupid. Below should replace current code inside outer if;

    // try and find the WP representation page - post_type IS required
    $query = new WP_Query(array('name' => $pagename, 'post_type' => 'page'));
    
    if (!$query->have_posts()) {
        // no WP page exists yet, so create one
        $id = wp_insert_post(array(
            'post_title' => $pagename,
            'post_type' => 'page',
            'post_status' => 'publish',
            'post_name' => $pagename,
            'post_author' => 1, // failsafe
            'post_content' => 'wp_insert_post needs content to complete'
        ));
    }
    
    // this sets up the main WordPress query
    // from now on, WordPress thinks you're viewing the representation page
    // post_type is a must!
    wp(array('name' => $pagename, 'post_type' => 'page'));
    
    // set up post
    the_post(); 
    

    P.S I think using the query_var name over pagename is better suited – it queries the slug, rather than the slug ‘path’.

    You’ll also need to either place an input inside the form with name redirect_to and a value of the URL you’d like to redirect to, or, filter the redirect with a function hooked onto comment_post_redirect, returning the correct URL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I am trying to use a bunch of custom perl modules, test.pm as
Currently, I use an abstract factory to allow the specification of a custom class
I want use html5's new tag to play a wav file (currently only supported
Currently, when I contribute property pages to Eclipse using the org.eclipse.ui.propertyPages extension point, the
Currently I am using UiService to create a form and I uses ListBox, from
Currently I am using HTML files for parts of my user interface. I display
currently, I`m implementing a map App with Mono4Droid and there I`m using a WebView
Currently i'm having trouble using two functions in my -(void)viewDidLoad , both of these
Currently I am using Amazon Cloudfront to service static objects on my ASP.Net MVC3
Currently, I have a log file of messages in one table in a MySQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.