0

Okay I have found the following code on line, which seems to be working and displaying all of the pages using the page_library_html.php template. This code only shows the title of them though. Can someone help me get the post content to show in as well as the title in .

Thanks in advance

Current code

<?php
        $product_pages_args = array(
    'meta_key' => '_wp_page_template',
    'meta_value' => 'page_library_html.php'
);

$product_pages = get_pages( $product_pages_args );
?>


<?php
foreach ( $product_pages as $product_page ) {
    echo '<div id="posts" class="flex_100"><div id="library_title"><a href="' . get_permalink( $product_page->ID ) . '">' . $product_page->post_title  . '</a>
    </div></div>';

}
?>
  • "Can you write code for me" is more of a request then a question, and one that has low chance of people replying to here. In addition your code doesn't seem to match your description. Please try to edit your question to improve it. – Mark Kaplun Jan 3 '14 at 5:01
0

Use get_post_field('post_content', $product_page->ID ) to get the content outside loop.

<?php
$product_pages_args = array(
    'meta_key' => '_wp_page_template',
    'meta_value' => 'page_library_html.php'
);
$product_pages = get_pages( $product_pages_args );
?>

<?php
foreach ( $product_pages as $product_page ) {
    echo '<div id="posts" class="flex_100">';
    echo '<div id="library_title"><a href="' . get_permalink( $product_page->ID ) . '">' . $product_page->post_title  . '</a></div>';
    echo '<div class="page-content">' . get_post_field('post_content', $product_page->ID ) . '</div></div>';
}
?>
  • Thanks so much @Subharanjan I've been looking for the answer for ages. – aled2305 Dec 28 '13 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.