The MU forums have moved to WordPress.org

Most recent posts from specific categories? (13 posts)

  1. dutchy4c
    Member
    Posted 16 years ago #

    On my http://www.newsturtle.com site I have installed Andrea-r & Ron's plug-in for most recent posts, and it works perfectly (thank you Andrea & Ron).
    I also want to make separate boxes showing the most recent posts (site-wide of course) per select categories. For instance the latest 5 under the Politics category, the 5 latest under the culinary category etc.

    Is there a known plug-in for this, or can someone write this plug-in (for a fee of course)?

  2. dutchy4c
    Member
    Posted 16 years ago #

    I have the "latest per category" plugin running, but this not quite what I was looking for. I want to set certain categories, the ones I deem most interesting to visitors, and have each of them in a separate little block with their 5 latest posts, so maybe 6 of these blocks in total.

    Also, I find that the space underneath each posting is rather optimistic (wasting too much valuable reading space), but can not find anything in the CSS nor in any other php file that influences this.

    Any help is really appreciated.

  3. andrea_r
    Moderator
    Posted 16 years ago #

    Lemme talk to Ron and see if he has time to do the "by category" part.

  4. dutchy4c
    Member
    Posted 16 years ago #

    Thanks Andrea. I am pretty proud of myself, since I was up till 3 last night getting the GT_SEARCH_ALL_BLOGS to work without distorting the theme. I still can't program, but am starting to see a little logic. Didn't help the plugin was in Italian though. ;-)

  5. dronamraju
    Member
    Posted 16 years ago #

    hi,

    Where is the "latest per category" plugin? I was looking on wpmudev.org. Is that the right place to be looking for?

  6. indojepang
    Member
    Posted 16 years ago #

    need this too.. i think it's not hard to do for you programmers :)

  7. tdjcbe
    Member
    Posted 16 years ago #

    i think it's not hard to do for you programmers

    Actually it's very easy but that smart ass response is why most of the folks who used to help out here are no longer here.

  8. andrea_r
    Moderator
    Posted 16 years ago #

    Actually - I asked Ron about this and it is not "easy". At least not as easy as it seems. To make our most recent posts plugin sort by category and display that way would involve doubling the amount of code in it. And he hasn't had the time.

  9. indojepang
    Member
    Posted 16 years ago #

    thank u.. andrea for trying to help us..
    still waiting for miracle..:)

  10. indojepang
    Member
    Posted 16 years ago #

    I found these.. forgot where..:(
    But it generated by Tags not Category, but I think it should be easy now for modify.. isn't it andrea?

    easy for u developers.. not for me.. :D

    
    <?php
    /*
    Plugin Name: WordPress MU Recent Posts
    Plugin URI: http://atypicalhomeschool.net/wordpress-plugins/
    Description: Retrieves a list of the most recent posts in a WordPress MU installation. Based on (Andrea - fill this in)
    Version: 0.3
    Author: Ron Rennick
    Author URI: http://atypicalhomeschool.net/
    
    Use this by pasting the following wherever you want it to show:
    <?php ah_recent_posts_mu(10) ?>
    
    */
    
    function ah_recent_posts_mu($how_many = 10) {
    	global $wpdb;
    	$counter = 0;
    	// get a list of blogs in order of most recent update
    	$blogs = $wpdb->get_col("SELECT blog_id
    							FROM $wpdb->blogs
    							WHERE last_updated >= DATE_SUB(CURRENT_DATE(), INTERVAL 5 DAY)
    							ORDER BY last_updated DESC");
    
    	if ($blogs) {
    		foreach ($blogs as $blog) {
    			// we need _posts and _options tables for this to work
    			$blogOptionsTable = "wp_".$blog."_options";
    		    $blogPostsTable = "wp_".$blog."_posts";
    		    $blogTaxonomyTable = "wp_".$blog."_term_taxonomy";
    		    $blogRelationshipsTable = "wp_".$blog."_term_relationships";
    		    $blogTermsTable = "wp_".$blog."_terms";
    
    			$options = $wpdb->get_results("SELECT option_value FROM
    										   $blogOptionsTable
    										   WHERE option_name IN ('siteurl','blogname')
    										   ORDER BY option_id, option_name DESC");
    
    		    // we fetch the title and link for the latest post
    			$thispost = $wpdb->get_results("SELECT post_title, guid, post_content, post_date, user_login, $blogTaxonomyTable.term_taxonomy_id, $blogTaxonomyTable.term_id, taxonomy, $blogRelationshipsTable.term_taxonomy_id, $blogTermsTable.term_id, taxonomy, object_id, name, $blogPostsTable.ID
    											FROM $blogPostsTable, wp_users, $blogTaxonomyTable, $blogRelationshipsTable, $blogTermsTable
    											WHERE wp_users.ID = $blogPostsTable.post_author
    											AND $blogTermsTable.name = ''
    											AND post_status = 'publish'
    											AND taxonomy = 'post_tag'
    											AND post_type = 'post'
    											AND $blogPostsTable.ID = object_id
    											AND $blogTermsTable.term_id = $blogTaxonomyTable.term_id
    											AND $blogTaxonomyTable.term_taxonomy_id = $blogRelationshipsTable.term_taxonomy_id
    											AND post_date >= DATE_SUB( CURRENT_DATE( ) , INTERVAL 5 DAY )
    											ORDER BY $blogPostsTable.id DESC
    											LIMIT 0 , 1 ");
    
    			// if it is found put it to the output
    			if($thispost) {
    			// pull in the posts content from database
    			$desc = $thispost[0]->post_content;
    			// save the post date to a var
    			$date = strtotime($thispost[0]->post_date);
    			// strip out html characters to allow for truncating
    			$strippedDesc = strip_tags($desc);
    			// truncate post content to 120 words
    			$numwords = 120;
     			preg_match("/([\S]+\s*){0,$numwords}/", $strippedDesc, $regs);
    		    $shortDesc = trim($regs[0]);
    				// Displays the post title url truncted text, author and blog name
    				echo '
    					<h2>guid.'">'.$thispost[0]->post_title.'</h2>
    
    by: '.$thispost[0]->user_login.' || from: option_value.'">'.$options[1]->option_value.'
    <p>'.$shortDesc.'guid.'"> [more]</p> '; $counter++; } // don't go over the limit if($counter >= $how_many) { break; } } } } ?>
  11. indojepang
    Member
    Posted 16 years ago #

    just fill the $blogTermsTable.name = '' with your tag.

    Sorry for the code.. next time where do i put these long code?

  12. tdjcbe
    Member
    Posted 16 years ago #

    next time where do i put these long code?

    From the debugging page:

    Also please don't post files within the forum unless asked to do so. Since the forum software will occasionally cause problems with formatting or strip out parts of the code, it's best to place the code within your site as a *.txt or *.phps file and link to it from your post.

    Thank you for noticing though that it didn't work. :)

  13. indojepang
    Member
    Posted 16 years ago #

    thanks tdjcbe! :D

About this Topic

  • Started 16 years ago by dutchy4c
  • Latest reply from indojepang