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 7837949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:55:33+00:00 2026-06-02T14:55:33+00:00

After the user clicks a link, I want to load the corresponding page within

  • 0

After the user clicks a link, I want to load the corresponding page within the currentpage. This ajaxpage should be themed differently than it’s non-ajax page.

The pages would be added by the client in different languages. So there is no fixed id’s and the client shouldnt add the same article twice (1 for normal and 1 for ajax). This rules manually overwriting templates out.

The first part, ajax loading of content is easy to do, but I don’t know how to display content in different ways.

So

domain.com/product/car direct visit shows a product (car) using single-product.php as template which includes a header and footer.

ajax loading domain.com/product/car would show a product (car) but without a header and footer and perhaps some small layout changes.

My initial thought would be setting some template dynamicly (template-product-ajax.php) but Im not sure if this is possible or how.

In short, how can I create a different template/layout/view when loading a page with ajax in wordpress

  • 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-06-02T14:55:36+00:00Added an answer on June 2, 2026 at 2:55 pm

    You would have to pass in a series of variables, including the page/post ID you want to load, what kind of object you’re trying to load (either ‘page’ or ‘post’) and a boolean to ensure that the standard get_header() function isn’t loaded (as you only want the content of the page, not the headers).

    Somewhere within the template, you can use that boolean to determine the template’s behavior. For example:

    <?php
    /*Template Name: AJAX Content*/
    if(!isset($_POST['bool']))
        get_header();
    ?>
    <div id="body">
        <div class="page_content">
        <?php
            if(isset($_POST['bool']))
            {
                $object = $_POST['ob_type'] == 'page' ? get_page($_POST['PID']) : get_post($_POST['PID']);
                echo $object->post_content;
                /*echo '<pre>';var_dump($object);echo '</pre>';//Uncomment this section if you want to know what you can access with variable $object*/
            {
            else
            {
                //STANDARD LOOP
            }
        ?>
        </div>
    </div>
    

    This is untested, but it should help get you started if you’re already familiar with AJAX calls and sending POST data to a separate page.

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

Sidebar

Related Questions

I want my recaptcha to appear only after user clicks submit button on the
I want to call setTimeout() after a click occurs. If the user clicks again
what i want to do is while user click the link, the clicks will
I'm trying to add a $('body').live('click') listener after the user clicks on a div.
I want to INSERT VALUES after user has clicked OK on the confirmation box.
I want to show an error (in phpBB it's trigger_error) right after the user
I'm wondering how I can show multiple divs after a user clicks on an
I have 3 different lists (ul). Each time a user clicks a link, I
I want the user to be redirected to a particular webpage after logging in
As the title says. I want to create TooltipDialog, after I click link and

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.