Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Way to get individual pages?
#1
I am doing a site that has multiple pages on one page....is there a way I can load the home page via get_page_content and then use another function to get an about page or something like that?
------
I can't design for shit but I can code the shit out of your design
Reply
#2
Derek Wrote:I am doing a site that has multiple pages on one page....is there a way I can load the home page via get_page_content and then use another function to get an about page or something like that?

you could always use multiple wysiwyg editors (using Custom Fields plugin)
Reply
#3
I use the following function to do this (place this function inside the "functions.php" file within your theme folder).

Code:
function get_content($page){

    $item = array();

    $path = "data/pages";
    $thisfile = @file_get_contents('data/pages/'.$page.'.xml');
    $data = simplexml_load_string($thisfile);
    
    //print_r($data);
            
    $item['content'] = stripslashes(htmlspecialchars_decode($data->content, ENT_QUOTES));
    $item['title'] = $data->title;
    $item['pubDate'] = $data->pubDate;
    $item['url'] = $data->url;
    $item['private'] = $data->private;
    $item['parent'] = $data->parent;
    $item['menuOrder'] = $data->menuOrder;
    
    return $item;
    
}

To call the function, you should pass the slug of the page you're trying to retrieve. The function will return an array containing several specifics for that page. To echo the content of the page, do something like:

Code:
$page = get_content('my-page');

echo $page['content'];

- Matt
Reply
#4
Derek Wrote:I am doing a site that has multiple pages on one page....is there a way I can load the home page via get_page_content and then use another function to get an about page or something like that?

If you use the I18N Plugin, you can use
Code:
<?php get_i18n_content('my-page-slug'); ?>
to include the content of page my-page-slug in the template or a component.

If you want to include the content of one page within another,
  • create a component named content:
Code:
<?php
global $args;
if (count($args) > 0) get_i18n_content($args[0]);
?>
  • install the DynPages plugin
  • include the text {% content my-page-slug %} in a page where you want to include the content of page my-page-slug
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply




Users browsing this thread: 1 Guest(s)