• Hello guys, thank you in advance for any help that comes from this….

    Basically I am creating a mixed site that the home page echoes out the content of each page I list in the the template file. The problem is I am using the $page_data = get_page
    to pull the individual pages, and then structure them to meet my design. I have been through the forum and each link in the forum to the referenced pages, but still can’t seem to get the filters to work. I am struggling because the get_page call breaks my plugins due to the text being shown as raw data. here’s what I have currently. I have stripped all non-working code out.

    Could someone show me how to add a filter to what i have so that short codes work on the home page?

    here’s what I have so far:

    <?php
    /**
     * Template Name: Home Single Page
     *
     * Description: Twenty Twelve loves the no-sidebar look as much as
     * you do. Use this page template to remove the sidebar from any page.
     *
     * Tip: to remove the sidebar from all posts and pages simply remove
     * any active widgets from the Main Sidebar area, and the sidebar will
     * disappear everywhere.
     *
     * @package WordPress
     * @subpackage Twenty_Twelve
     * @since Twenty Twelve 1.0
     */
    get_header(); ?>
    
    <?php echo get_post_meta($post->ID,'custom-field-name',true) ?> 	<div id="primary" class="site-content">
    		<div id="content" role="main">
    
    <!--Home Page Creativity Labs-->
    
    <?php
    $page_id = 8; // 123 should be replaced with a specific Page's id from your site, which you can find by mousing over the link to edit that Page on the Manage Pages admin page. The id will be embedded in the query string of the URL, e.g. page.php?action=edit&post=123.
    
    $page_data = get_page( $page_id ); // You must pass in a variable to the get_page function. If you pass in a value (e.g. get_page ( 123 ); ), WordPress will generate an error. By default, this will return an object.
    
    echo "<h1 id=\"cl\" class=\"entry-title, banner\">". $page_data->post_title ."</h1>"
    ."<div class=\"entry-content\">".$page_data->post_content."</div>";// echo the title
    
    ?>
    
    <!--About Page Creativity Labs-->
    <?php
    $page_id = 10; // 123 should be replaced with a specific Page's id from your site, which you can find by mousing over the link to edit that Page on the Manage Pages admin page. The id will be embedded in the query string of the URL, e.g. page.php?action=edit&post=123.
    
    $page_data = get_page( $page_id ); // You must pass in a variable to the get_page function. If you pass in a value (e.g. get_page ( 123 ); ), WordPress will generate an error. By default, this will return an object.
    
    echo "<h1 id=\"abt\" class=\"entry-title, banner\">". $page_data->post_title ."</h1>"
    ."<div class=\"entry-content\">".$page_data->post_content."</div>";// echo the title
    
    ?>
    
    <!--Events Page Creativity Labs-->
    
    <?php
    $page_id = 16; // 123 should be replaced with a specific Page's id from your site, which you can find by mousing over the link to edit that Page on the Manage Pages admin page. The id will be embedded in the query string of the URL, e.g. page.php?action=edit&post=123.
    
    $page_data = get_page( $page_id ); // You must pass in a variable to the get_page function. If you pass in a value (e.g. get_page ( 123 ); ), WordPress will generate an error. By default, this will return an object.
    
    echo "<h1 id=\"evt\" class=\"entry-title, banner\">". $page_data->post_title ."</h1>"
    ."<div class=\"entry-content\">".$page_data->post_content."</div>";// echo the title
    
    ?>
    
    <!--Our Tribe Page Creativity Labs-->
    
    <?php
    $page_id = 14; // 123 should be replaced with a specific Page's id from your site, which you can find by mousing over the link to edit that Page on the Manage Pages admin page. The id will be embedded in the query string of the URL, e.g. page.php?action=edit&post=123.
    
    $page_data = get_page( $page_id ); // You must pass in a variable to the get_page function. If you pass in a value (e.g. get_page ( 123 ); ), WordPress will generate an error. By default, this will return an object.
    
    echo "<h1 id=\"trb\" class=\"entry-title, banner\">". $page_data->post_title ."</h1>"
    ."<div class=\"entry-content\">".$page_data->post_content."</div>";// echo the title
    
    ?>
    
    <!--Conect Page Creativity Labs-->
    
    <?php
    $page_id = 81; // 123 should be replaced with a specific Page's id from your site, which you can find by mousing over the link to edit that Page on the Manage Pages admin page. The id will be embedded in the query string of the URL, e.g. page.php?action=edit&post=123.
    
    $page_data = get_page( $page_id ); // You must pass in a variable to the get_page function. If you pass in a value (e.g. get_page ( 123 ); ), WordPress will generate an error. By default, this will return an object.
    
    echo "<h1 id=\"cnt\" class=\"entry-title, banner\">". $page_data->post_title ."</h1>"
    ."<div class=\"entry-content\">".$page_data->post_content."</div>";// echo the title
    ?>
    </div><!-- #content -->
    	</div><!-- #primary -->
    
    <?php get_footer(); ?>

    How can I get each page to display the short codes?

    The site is live here

Viewing 1 replies (of 1 total)
  • Thread Starter cjvalotta

    (@cjvalotta)

    So nevermind, I figured out how to do it using:

    <?php
    $page_id = 8; // 123 should be replaced with a specific Page's id from your site, which you can find by mousing over the link to edit that Page on the Manage Pages admin page. The id will be embedded in the query string of the URL, e.g. page.php?action=edit&post=123.
    
    $page_data = get_page( $page_id ); // You must pass in a variable to the get_page function. If you pass in a value (e.g. get_page ( 123 ); ), WordPress will generate an error. By default, this will return an object.
    $content = apply_filters('the_content', $page_data->post_content);
    echo "<h1 id=\"cl\" class=\"entry-title, banner\">". $page_data->post_title ."</h1>"
    ."<div class=\"entry-content\">".$content."</div>";// echo the title
    
    ?>

    Applying the following filter:
    $content = apply_filters('the_content', $page_data->post_content);

    and using:
    .$content.
    in place of
    .$page_data->post_content.
    allows me to pull the actual content instead of the raw text.

    Hope this helps anyone looking for an answer to this.

Viewing 1 replies (of 1 total)
  • The topic ‘Getting short codes to work with a $get_page call’ is closed to new replies.