The following warnings occurred:
Warning [2] Undefined array key "threadviews_countguests" - Line: 745 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php 745 errorHandler->error_callback
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/inc/functions_post.php 830 postParser->parse_message
/showthread.php 916 build_postbit
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/inc/functions_post.php 861 postParser->parse_message
/showthread.php 916 build_postbit
Warning [2] Undefined property: MyLanguage::$thread_modes - Line: 46 - File: showthread.php(1650) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php(1650) : eval()'d code 46 errorHandler->error_callback
/showthread.php 1650 eval




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Way to get individual pages?
#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


Messages In This Thread
Way to get individual pages? - by Derek - 2011-09-06, 08:57:27
Way to get individual pages? - by mikeh - 2011-09-06, 11:37:11
Way to get individual pages? - by getsimplethemes - 2011-09-06, 14:39:49
Way to get individual pages? - by mvlcek - 2011-09-06, 15:47:56



Users browsing this thread: 1 Guest(s)