Support » Themes and Templates » [TwentyEleven] Page content inside sidebar

  • is it possible to get the content of the a page( that has posts with thumbnails and excerpts) to be automaticaly copied to the sidebar of the homeage in a miniaturized state?
    i am using a child theme of course.

Viewing 15 replies - 1 through 15 (of 29 total)
  • i have tryed using this script :
    <?php
    $evenimente_id = 54; // substitute page_id of about for “2”
    $evenimente_page = get_post($about_id);
    echo “<p>$evenimente_page->post_content</p>”;
    ?>

    where 54 is the id of the evenimente page. i have copied the sidebar.php to my child theme and added the script and after that everything in the sidebar disapears, even the widgets. maybe i’m not putting it where i should…

    @apoklyps3
    yes, it is passible to get the content of the a page. you have to follow this link http://wordpress.org/extend/plugins/page-in-widget/installation/

    ok…will give it a try. is it possible by code only also? i have read that plugins slow down the loading of the page, so i wanna keep the plugins to a minimum necesary.

    you have to add this code in sidebar.php of your theme.

    <?php
              $page_id = 2;  // edit here the id of the page
              $page_data = get_page( $page_id );
              echo '<h3>'. $page_data->post_title .'</h3>';
              echo apply_filters('the_excerpt', $page_data->post_content);
          ?>

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code may now have been permanently damaged/corrupted by the forum’s parser.]

    ok …remember i am using a child them.
    i have put this with my page id, 54, but just the tile has appeared but not in the sidebar, bellow the main content. i used the code in sidebar.php, why does it get bellow my posts and it doesn’t even show all the page content , just the title?

    ok so i got it to show in the sidebar instead bellow the content, but only the tile of the page appears.

    esmi

    (@esmi)

    Forum Moderator

    Do not edit the Twenty Eleven theme. It is the default WordPress theme and having access to an unedited version of the theme is vital when dealing with a range of site issues. First create a child theme for your changes.

    i have already stated i am using a child theme. did you not read my posts?

    esmi

    (@esmi)

    Forum Moderator

    Then where is the link to your site?

    esmi

    (@esmi)

    Forum Moderator

    Try:

    <?php
    $args = array( 'p' => 54 );
    $evenimente = get_posts( $args );foreach($$evenimente as $post) : setup_postdata($post); ?>
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    <?php the_content(); ?>
    <?php endforeach; ?>

    http://codex.wordpress.org/Template_Tags/get_posts

    it gives me an error regarding to this line:
    $evenimente = get_posts( $args );foreach($$evenimente as $post) : setup_postdata($post); ?
    could it be the “$$evenimente”? i tryed to change it to
    $evenimente” , no error anymore , but still nothing appears as you can test again.

    esmi

    (@esmi)

    Forum Moderator

    Sorry – typo. Change foreach($$evenimente as $post) : to foreach($evenimente as $post) :

    yeah already tryed that. no error , but also nothing appears. take a look now.

    esmi

    (@esmi)

    Forum Moderator

    <?php
    $args = array( 'p' => 54 );
    $evenimente = get_posts( $args );
    foreach($evenimente as $post) :
    setup_postdata($post); ?>
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    <?php the_content(); ?>
    <?php endforeach; ?>

    should work. What’s the error in the server’s error logs?

Viewing 15 replies - 1 through 15 (of 29 total)
  • The topic ‘[TwentyEleven] Page content inside sidebar’ is closed to new replies.