• Resolved yolise

    (@yolise)


    I did a brief search for this, but I can’t think of the best way to describe it, so am having trouble getting results that are relevant…

    I have a basic WP blog and I want to display pages in the blog in two different ways:

    1. Standard Page layout on the blog as per the standard templates

    2. Via a jQuery iFrame or AJAX call on another site, but styled differently. I would need to somehow create a static page for this to do it via AJAX or be able to style the page differently if using an iFrame.

    Is there a way to create two differently styled versions of the same page?

    Or alternatively, dump text-only content from a page?

    I hope this makes sense!

Viewing 11 replies - 1 through 11 (of 11 total)
  • Have you looked at creating a custom page template?

    Thread Starter yolise

    (@yolise)

    I’ve used them before, but can you apply two different templates to the same page? And how would you call one rather than the other?

    In other words, I want to create two different page templates and apply them to one page entry. So, I would, for example have the page entry “About” styled using Template A if called from the blog, but styled using Template B if called from another location (say, from the homepage).

    It’s about re-using content, basically.

    Create a new (dummy) page and apply the custom template that calls your About page?

    Thread Starter yolise

    (@yolise)

    I’m not sure I follow.

    In WordPress, I know I can set a page to use a custom template in “attributes”, but I want to use two different templates, depending on where the page is linked from.

    So,

    https://www.blah.com/home/ link to “About Page” uses Template A

    https://www.blah.com/blog/ link to “About Page” uses Template B

    where “About Page” is the same WordPress page entry in both situations.

    There are several ways to do this, many of which are probably more complicated than you need. You could check the referrer url or pass in URL params and change classnames as needed, or you could do what esmi is talking about and create a duplicate page. In the custom template on the dupe page you would simply change:
    if (have_posts()) : while (have_posts()) : the_post();
    to:

    query_posts("p=14");
    if (have_posts()) : while (have_posts()) : the_post();

    changing “14” in this example to your relevant page id.

    Thread Starter yolise

    (@yolise)

    I was going to check the referrer url as a last resort, but it would get complicated because in one instance the template needs the header, sidebars and footer, but in the other needs only the content of the entry.

    The problem with creating a duplicate page entry is that it’s not really reusing content. It means making a change to two different page entries whenever the information needs to change.

    I might as well just hard-code the page in that case.

    Is there a way to get the xml of an individual page? I could parse that in an alternative layout…

    query_posts(“p=14”); pulls the content from page id 14, so you have two pages but you only edit the content of page id 14.

    Thread Starter yolise

    (@yolise)

    Ah! Ok, that’s perfect – thanks!

    How would you call that page url?

    Thread Starter yolise

    (@yolise)

    Any idea how to build a url for a specific page template?

    I’ve been through the docs over and over and still haven’t seen any way to specify a particular template in a url.

    Thread Starter yolise

    (@yolise)

    I’m wondering if I still don’t understand this. When you say “dummy page” or “duplicate page”, what is meant here? Creating a duplicate page in the Word Press control panel? Why would I only need to edit one of them? Won’t both pages show up on the blog navigation? Or would I have to hardcode the links on the blog index?

    Thread Starter yolise

    (@yolise)

    Right. I answered my own question and figured it out. I use exclude to leave out the dummy page from the navigation.

    Only clarification for anyone else that finds this,

    query_posts(“p=14”); didn’t work, but query_posts(‘page_id=14’); does.

    Thanks for the help!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Displaying a page two different ways’ is closed to new replies.