WordPress.org

Ready to get started?Download WordPress

Forums

[TwentyEleven] Page content inside sidebar (30 posts)

  1. apoklyps3
    Member
    Posted 2 years ago #

    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.

  2. apoklyps3
    Member
    Posted 1 year ago #

    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...

  3. radhika
    Member
    Posted 1 year ago #

    @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/

  4. apoklyps3
    Member
    Posted 1 year ago #

    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.

  5. radhika
    Member
    Posted 1 year ago #

    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.]

  6. apoklyps3
    Member
    Posted 1 year ago #

    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?

  7. apoklyps3
    Member
    Posted 1 year ago #

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

  8. esmi
    Forum Moderator
    Posted 1 year ago #

    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.

  9. apoklyps3
    Member
    Posted 1 year ago #

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

  10. esmi
    Forum Moderator
    Posted 1 year ago #

    Then where is the link to your site?

  11. apoklyps3
    Member
    Posted 1 year ago #

  12. esmi
    Forum Moderator
    Posted 1 year ago #

    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

  13. apoklyps3
    Member
    Posted 1 year ago #

    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.

  14. esmi
    Forum Moderator
    Posted 1 year ago #

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

  15. apoklyps3
    Member
    Posted 1 year ago #

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

  16. esmi
    Forum Moderator
    Posted 1 year ago #

    <?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?

  17. apoklyps3
    Member
    Posted 1 year ago #

    now there is no more error. anyways still not working. nothing appears, probabily i will end up using a plugin after all since nothing seems to work :(

  18. radhika
    Member
    Posted 1 year ago #

    @apoklyps3
    you have to need to replace the 'the_excerpt' by the 'the_content' in the code.

    <?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_content', $page_data->post_content);
          ?>
  19. apoklyps3
    Member
    Posted 1 year ago #

    i have found that not even with the plugin the page doesn't show in the sidebar(only page title shows up). there must be something else wrong, perhaps in the styling. i will have to do some trial and error tests to see what causes this. thanks to all for the replies.

  20. apoklyps3
    Member
    Posted 1 year ago #

    i don't know what's wrong, not even plugins get the job done.t it simply doesn't display anything. i have tryed disabling one by one the child themes files and still nothing new shows up.

  21. radhika
    Member
    Posted 1 year ago #

    @apoklyps3
    are you dragged the widget 'page in widget' in sidebar and select the template of the page.

  22. apoklyps3
    Member
    Posted 1 year ago #

    yes. also callendar. callendar widget shows on the page, page in widget not.

  23. alchymyth
    Forum Moderator
    Posted 1 year ago #

    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?

    not really possible; if at all, definitively not easy;

    - you could add pages and/or posts to the sidebar (as mentioned in previous replies), but you will have to re-programm the output and layout etc.

    - you could use: wp_remote_get() http://codex.wordpress.org/Function_API/wp_remote_get and extract whatever part you want to show; and for the 'miniaturized' possibly use jQuery (no idea if this is at all possible), or add a totally new set of styles.

  24. radhika
    Member
    Posted 1 year ago #

    And you follow this code in sidebar.php template of your theme.

    <?php
           $page_id = 54;  // edit here the id of the page
           $page_data = get_page( $page_id );
            echo '<h3>'. $page_data->post_title .'</h3>';
            echo apply_filters('the_content', $page_data->post_content);
       ?>
  25. apoklyps3
    Member
    Posted 1 year ago #

    @arti singh
    yes. only the title of the page shows on the sidebar and nothing more. as i said it's really strange. i'm sure i must have broken something somewhere else if it doesn't even work with plugins. but i don't know where.
    @alchymyth
    you're right seems complicated. is the same situation for just displaying the posts of a page inside the sidebar?

  26. alchymyth
    Forum Moderator
    Posted 1 year ago #

    just displaying the posts of a page inside the sidebar?

    all depends on the level of control you want to have over the layout;
    with restrictions, this might be possible with one of the 'catgory posts' or 'recent posts' or similar widgets from a plugin;

    or by re-creating the same query, which is used in that page, to get the list of posts; and apply similar formatting as used on that page.

    which page of your site do you want to show miniaturized in the sidebar?

    and why?
    what is the purpose of showing a miniaturized page?

  27. apoklyps3
    Member
    Posted 1 year ago #

    the page si the only page created with one test post: Evenimente .
    i am very sure it's something i did to my functions.php child file:

    <?php add_image_size( 'thumbnail-feature', 860, 550);
    add_image_size( 'thumbnail-feature-side', 350, 282);
    add_filter('body_class', 'adjust_body_class', 20, 2);
    
    /**
     * Prints HTML with meta information for the current post-date/time and author.
     * Create your own twentyeleven_posted_on to override in a child theme
     *
     * @since Twenty Eleven 1.0
     */
    function dr_header_image_width($size) { return 1250; }
    add_filter('twentyeleven_header_image_width', 'dr_header_image_width');
    function dr_header_image_height($size) { return 91; }
    add_filter('twentyeleven_header_image_height', 'dr_header_image_height');
    function twentyeleven_posted_on() {
    	printf( __( '<span class="by-author"> <span class="sep"> de </span> <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span><span class="sep">scris </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s" pubdate>%4$s</time></a>', 'twentyeleven' ),
    		esc_url( get_permalink() ),
    		esc_attr( get_the_time() ),
    		esc_attr( get_the_date( 'c' ) ),
    		esc_html( get_the_date() ),
    		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    		esc_attr( sprintf( __( 'View all posts by %s', 'twentyeleven' ), get_the_author() ) ),
    		get_the_author()
    	);
    }
    add_filter('body_class', 'adjust_body_class', 20, 2);
    function adjust_body_class($wp_classes, $extra_classes) { 
    
    if( is_page_template('evenimente.php') ) :
    // Filter the body classes     
    
          foreach($wp_classes as $key => $value) {
          if ($value == 'singular') unset($wp_classes[$key]);
          }
    
    endif;
    // Add the extra classes back untouched
    return array_merge($wp_classes, (array) $extra_classes );
    }
    function excludeCat($query) {
      if ( $query->is_home ) {
        $query->set('cat', '-7');
      }
      return $query;
    }
    add_filter('pre_get_posts', 'excludeCat');
    function includeCat($query) {
      if ( $query->is_page('evenimente') ) {
        $query->set('cat', '7');
      }
      return $query;
    }
    add_filter('pre_get_posts', 'includeCat');
    ?>

    at first i thought it was the function to exclude cat 7 from homepage, but it doesn't see to be that. i have removed it and still nothing

  28. apoklyps3
    Member
    Posted 1 year ago #

    is there something wrong with my functions.php child file?

  29. apoklyps3
    Member
    Posted 1 year ago #

    thanks all for the help . i resolved my problem in a different way. i used query posts by cat instead, wich practicaly did the same job, only that it's working.

  30. apoklyps3
    Member
    Posted 1 year ago #

    is it possible to get the posts but also with titles and separators betweend posts? so far it only shows the posts content.my code inside sidebar.php is:

    <div id="secondary" class="widget-area" role="complementary">
    <?php
    query_posts('cat=7');
    while (have_posts()) : the_post();
    the_content();
    endwhile;
    ?>
    		</div>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.