Support » Fixing WordPress » Get page

  • Resolved iversoncru

    (@iversoncru)


    Hi!
    i have been trying a simple code to get pages in one template, and i dont get it to work

    <article id="service">
    	<?php
    		echo $page_id = get_the_ID();
    		$page = get_page($page_id);
    	?>
    	<h2> <?php $page->post_title ?></h2>
    
    	<div id="service_content">
    		<?php apply_filters("the_content", $page->post_content);?>
    	</div>
    
    </article>

    Could anyone give me a small ray of sunshine? please!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Andrew Nevins

    (@anevins)

    Forum moderator

    Hi, can you say what exactly doesn’t work and how it doesn’t work? E.g does it throw an error, what error?

    Hi Andrew
    Thanks for your answer and time.
    The “error” was that nothing displayed… and now i have figured out… i didnt place “echo” to show title and content o.O

    <article id="service">
    	<?php
    		$page_id = get_the_ID();
    		$page = get_page($page_id);
    	?>
    	<h2> <?php echo $page->post_title ?></h2>
    
    	<div id="service_content">
    		<?php echo apply_filters("the_content", $page->post_content);?>
    	</div>
    
    </article>

    Sorry for the silly mistake- and therefore question .

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get page’ is closed to new replies.