WordPress.org

Forums

calling a post or page by id (2 posts)

  1. pdxDaniela
    Member
    Posted 1 year ago #

    I have created a form with easy form. I want to call it in a side bar i tried

    <?php
    $new_query = new WP_Query('contact' );
    while ( $new_query->have_posts() ) : $new_query->the_post();?>
    <?php endwhile; ?>

    I tried it w/$new_query = new WP_Query('p=120' ); &
    $new_query = new WP_Query('120' );
    etc...
    so far they are not working. when it is left empty it shows the post the page is on.
    How do i go about calling it?
    Thank you
    D

  2. Rajan V
    Member
    Posted 1 year ago #

    Hi pdxDaniela.,

    Use get_post() function.

    <?php
    $post_7 = get_post(7);
    $title = $post_7->post_title;
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.