• I want to create a WP Page that is excluded in the pages navigation, and instead have a sidebar section that uses a PHP include that pulls the page content.

    Reason: so a non-tech client can post ‘Announcements’ by just going into the ‘Announcements’ page and adding text content, and then the sidebar will pull that page content…

    Is this possible?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • This is possible. I just did this a few days ago for a client. Here’s the function I used:

    function show_post($path) {
      $post = get_page_by_path($path);
      $content = apply_filters('the_content', $post->post_content);
      echo $content;
    }

    And then to use that function you pass in the path to where the page is at, based on the page you use the function:

    show_post('path/to/page');

    This will pull the content from that page and display it wherever you call the function.

    Thread Starter derek642

    (@derek642)

    @dkotter – Thanks a lot, that worked pefectly! But I didnt’ have to use it as a function, I just copied the php script into the sidebar widget since I have the Exec-PHP plugin installed too…

    If I were to make this a function, where do I put the function scripting to call from? functions.php file in the theme?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHP include of WP Page in Sidebar?’ is closed to new replies.