The MU forums have moved to WordPress.org

Hacked Plugin for Sitewide Recent Posts (w/ Category Option) (11 posts)

  1. Vocino
    Member
    Posted 14 years ago #

    Hello,

    My company (Vocino Labs) recently built a new deployment of the Dine Magazine site on WordPress MU.

    I searched the forums and the various plugin sites for a simple plugin that would allow me to do what I wanted: Display the most recent posts across the network in a specific category. You can see what the actual implementation is at the footer-mid area of DineMag.net where the 4 columns are.

    Anyway, I found a lot of stuff that almost worked and some stuff that might work but they wanted some inflated (in my opinion) dollars for it, but nothing that was spot on.

    So I edited a version of ah_recent_posts_mu that I found to include the content without except while inserting paragraph html, grabbed a bit more from the database and, most important, allows for category arrays.

    Downloading, fork it, or whatever, on GitHub.

    Here's the call that's being used on the content area of DineMag.net:

    <?php muumuu_recent_posts(5, 100, true, '<div class="post">', '</div>'); ?>

    Here's the call that's being used on the first column of the lower part where the categories are:

    <h3>Restaurants</h3>
    <ul>
    	<?php muumuu_recent_posts(5, 100, false, '<li>', '</li>', array('Restaurants')); ?>
    </ul>

    The best way to ask me questions is probably via Twitter.

  2. mthoma
    Member
    Posted 14 years ago #

    which them page do you paste this in?

  3. mthoma
    Member
    Posted 14 years ago #

    I meant THEME page.

  4. miklb
    Member
    Posted 14 years ago #

    very cool.

    @mthoma, I imagine where ever in your theme you want this. I'm sure it has to be inserted into the template, unless you are running some kind of plugin that allows for PHP in content. Obvious places for this would be home.php, or a page specific plugin if using a page for the home page. I'd guess home.php.

  5. mthoma
    Member
    Posted 14 years ago #

    I'm using buddypress which this hack wasn't created for. I did see a couple home under:

    wp-content/tehmes/home/home
    and

    I didn't see any home under:
    wp-content/tehmes/bp-sn-parent
    wp-content/tehmes/bp-default

    any advice appreciated.

  6. mthoma
    Member
    Posted 14 years ago #

    I did manage to find wp-content/themes/bp-sn-parent/home and got RESTAURANT to appear on the home page. But I think that is just the beginning of getting it working with my categories:

    <?php get_header(); ?>

    <h3>Restaurants</h3>

      <?php muumuu_recent_posts(5, 100, false, '
    • ', '
    • ', array('Restaurants')); ?>

    <div id="content">

    <?php do_action( 'bp_before_home' ) ?>

    <div id="third-section" class="widget-section">
    <?php if ( !function_exists('dynamic_sidebar')
    || !dynamic_sidebar('third-section') ) : ?>

    <div class="widget-error">
    <?php _e( 'Please log in and add widgets to this section.', 'buddypress' ) ?> /wp-admin/widgets.php?s=&show=&sidebar=first-section"><?php _e( 'Add Widgets', 'buddypress' ) ?>
    </div>

    <?php endif; ?>
    </div>

    <div id="second-section" class="widget-section">
    <?php if ( !function_exists('dynamic_sidebar')
    || !dynamic_sidebar('second-section') ) : ?>

    <div class="widget-error">
    <?php _e( 'Please log in and add widgets to this section.', 'buddypress' ) ?> /wp-admin/widgets.php?s=&show=&sidebar=second-section"><?php _e( 'Add Widgets', 'buddypress' ) ?>
    </div>

    <?php endif; ?>
    </div>

    <div id="first-section" class="widget-section">
    <?php if ( !function_exists('dynamic_sidebar')
    || !dynamic_sidebar('first-section') ) : ?>

    <div class="widget-error">
    <?php _e( 'Please log in and add widgets to this section.', 'buddypress' ) ?> /wp-admin/widgets.php?s=&show=&sidebar=third-section"><?php _e( 'Add Widgets', 'buddypress' ) ?>
    </div>

    <?php endif; ?>
    </div>

    <?php do_action( 'bp_after_home' ) ?>

    </div>

    <?php get_footer(); ?>

  7. mthoma
    Member
    Posted 14 years ago #

    It's working fine, thanks for your help Mikelb.

  8. mthoma
    Member
    Posted 14 years ago #

    Now if I created a new page under myblog .com/restaurants where can I find that page to put in the new code?

  9. padma18885
    Member
    Posted 14 years ago #

    What should I do to display metadata / custom field of post ?

  10. Minotauro
    Member
    Posted 13 years ago #

    Vocino,

    Your plugin works great. Thank you for sharing with us.

    I'm trying to show the thumbnail for each post also on the main blog. I'm not sure if I need to edit your plugin or the index.php of my blog.

    Below is the code to pull the thumbnails.

    <?php
    					$w = 110;
    					$h = 75;
    					$postheader = '';
    
    					if(function_exists('p75GetThumbnail') && get_post_meta($post->ID, '_p75_thumbnail', true)) {
    						$postheader = '<a href="' . get_permalink() . '"><img src="' . p75GetThumbnail($post->ID, $w, $h, 'png') . '" alt="' . get_the_title() . '" title="' . get_the_title()	. '" /></a>';
    					} else {
    						if(wptap_post_thumb()) {
    							$postheader .= '<a href="' . get_permalink() . '"><img src="' . wptap_post_thumb($w,$h) . '" alt="' . get_the_title() . '" title="' . get_the_title()	. '" width="'.$w.'" height="'.$h.'" /></a>';
    						} else {
    								$postheader .= '<a href="' . get_permalink() . '"><span class="empty-thumb"></span></a>';
    						}
    					}
    
    					if(wptap_video_custom_field()) {
    						$postheader .= '<a href="' . wptap_get_video_permalink() . '"><span class="play-boutton"></span></a>';
    					}
    
    					echo $postheader;
    				?>

    Please show me how to add the thumbnail function to the call for your plugin. Thank you!

  11. rodrigomattos
    Member
    Posted 13 years ago #

    You guys seem to know about this stuff... I am not too familiar with wordpress.

    I install the plugin, then?

    What code and where should I place it?

    Please help.

About this Topic

  • Started 14 years ago by Vocino
  • Latest reply from rodrigomattos