WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Get page (3 posts)

  1. iversoncru
    Member
    Posted 1 year ago #

    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!

  2. Andrew
    Forum Moderator
    Posted 1 year ago #

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

  3. iversoncru
    Member
    Posted 1 year ago #

    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 .

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags