[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.
-
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 ??
@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); ?>
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.
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.
@apoklyps3
are you dragged the widget ‘page in widget’ in sidebar and select the template of the page.yes. also callendar. callendar widget shows on the page, page in widget not.
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()
https://codex.www.ads-software.com/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.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); ?>
@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?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?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
is there something wrong with my functions.php child file?
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.
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>
- The topic ‘[TwentyEleven] Page content inside sidebar’ is closed to new replies.