admin管理员组文章数量:1327945
I'm working on a school website. The design calls for a collection of largely static pages, but for each class to have a blog which will be updated every few days.
I know nothing about WordPress or PHP (thought I have development experience on other platforms) but I got the static bits of the site, based on a custom theme, up without too many problems.
I set up a page for each class blog but I really wanted the authors to use the blogging engine rather than just continually updating a page. To enable this I switched on multi-site, based on URL, and set up some blogs in the sub-site for each class.
However I'm now stuck on how to make the standard index.php I created for the static pages display blog content instead for certain sections of the site.
I'd also like to add a right-hand widget that will display the most recent three entries from blogs, regardless of what class their from.
Ideally I also need to add a date to the page title for blogs, but not for the static pages on the site.
Anyone help?
EDIT: Index.php code as requested
<div id="column-center">
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<p style="font-size:22px;"><?php the_title();?></p>
<hr class="hr-red" />
<div style="font-size:13px;">
<?php the_content(); ?>
</div>
<?php endwhile; endif; ?>
<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
</div>
I'm working on a school website. The design calls for a collection of largely static pages, but for each class to have a blog which will be updated every few days.
I know nothing about WordPress or PHP (thought I have development experience on other platforms) but I got the static bits of the site, based on a custom theme, up without too many problems.
I set up a page for each class blog but I really wanted the authors to use the blogging engine rather than just continually updating a page. To enable this I switched on multi-site, based on URL, and set up some blogs in the sub-site for each class.
However I'm now stuck on how to make the standard index.php I created for the static pages display blog content instead for certain sections of the site.
I'd also like to add a right-hand widget that will display the most recent three entries from blogs, regardless of what class their from.
Ideally I also need to add a date to the page title for blogs, but not for the static pages on the site.
Anyone help?
EDIT: Index.php code as requested
<div id="column-center">
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<p style="font-size:22px;"><?php the_title();?></p>
<hr class="hr-red" />
<div style="font-size:13px;">
<?php the_content(); ?>
</div>
<?php endwhile; endif; ?>
<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
</div>
Share
Improve this question
edited Nov 12, 2012 at 21:10
Bob Tway
asked Nov 12, 2012 at 19:38
Bob TwayBob Tway
1013 bronze badges
1
- Please show your current index.php code. – kaiser Commented Nov 12, 2012 at 20:05
1 Answer
Reset to default 0This can be achieved with the help of a plugin.
A custom, hand coded, solution can be built analyzing and modifying the code of such plugin(s).
Searching for "multisite + widget", I found one plugin of interest.
Multisite Posts
Get posts from another child site in a multisite setup. You can also integrate the plugin into your theme file, very efficient. Offers shortcode and widget for feature usage. Internationalization ready.
Seems well coded, is up to date with the latest WordPress version (3.4.2) and may solve the index.php
issue (via shortcode) and the widget too.
Caveat is that each site has to be manually added (1 shortcode/widget per site).
Custom Shortcode to Use with the Plugin
Automates what would be a manually typed list of shortcodes.
add_shortcode( 'blogs_posts', 'wpse_72355_blogs_posts' );
function wpse_72355_blogs_posts( $attr )
{
global $wpdb;
$blogs = $wpdb->get_results($wpdb->prepare("
SELECT blog_id
FROM {$wpdb->blogs}
WHERE site_id = '{$wpdb->siteid}'
AND spam = '0'
AND deleted = '0'
AND archived = '0'
AND mature = '0'
AND public = '1'
"));
$the_blogs_posts = '';
foreach ($blogs as $blog)
{
$details = get_blog_details( $blog->blog_id );
$the_blogs_posts .= 'From the site: <a href="'
. $details->siteurl . '">'
. $details->blogname . '</a><br>';
$the_blogs_posts .= do_shortcode(
'[multisite_posts no="' . $attr['no']
. '" site_id="' . $blog->blog_id . '"]'
);
}
return $the_blogs_posts;
}
The foreach ($blogs as $blog)
could be adapted to work like this:
$original_blog_id = get_current_blog_id();
foreach ($blogs as $blog)
{
switch_to_blog( $blog->blog_id );
// http://codex.wordpress/Function_Reference/get_posts
$posts_array = get_posts( $args );
// Iterate through $posts_array and build the output
}
switch_to_blog( $original_blog_id );
本文标签: pluginsPulling subsite content into specific pages
版权声明:本文标题:plugins - Pulling sub-site content into specific pages 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742213763a2434189.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论