The MU forums have moved to WordPress.org

Customizing WP-Autoblog Output (4 posts)

  1. bwinn
    Member
    Posted 15 years ago #

    The WP Autoblog plugin is great. It allows you add multiple feeds from external sites or blogs which act as normal posts. The problem I am having with this plugin is that I want the post title to link to the actual blog post from the feed, as opposed to keeping it on my blog and going to the single.php page.

    For example I have multiple feeds that are syndicated on my homepage using autoblog, but I have blog 1 which is on my list of feeds that autoblog uses. Instead of the blog going to blog 1 or http://blog1.mysite.com/post it stays on my blog and goes to http://mysite.com/post.

    Here is the code from the plugin that I need to modify but I am not a php expert: (I can usually modify things here and there but this ones is beyond me)

    // Title
    			$post['post_title'] = strip_tags(trim($item['title']));
    
    			// Categories
    			$post['post_category'] = array();
    			if(isset($item['category#'])){
    				for ($i = 1; $i <= $item['category#']; $i++){
    					$cat_idx = (($i > 1) ? "#{$i}" : "");
    					$cat = $item["category{$cat_idx}"];
    					$post['post_category'][] = $cat;
    				}
    			} else if($item['dc']['subject'] != ""){
    				$post['post_category'][] = $item['dc']['subject'];
    			}
    
    			for($i = 0; $i < count($post['post_category']); $i++){
    				$post['post_category'][$i] = $wpdb->escape($post['post_category']);
    				$post['post_category'][$i] = lookup_cat(strip_tags(trim($post['post_category'][$i])));
    			}
    
    			// Post date
    			$date = "";
    			if($item['published'] != "") $date = auto_blog_parse_w3cdtf($item['published']); // Atom 1.0
    			else if($item['issued'] != "") $date = auto_blog_parse_w3cdtf($item['issued']);	// Atom 0.3
    			else if($item['dcterms']['issued'] != "") $date = auto_blog_parse_w3cdtf($item['dcterms']['issued']);
    			else if($item['dc']['date'] != "") $date = auto_blog_parse_w3cdtf($item['dc']['date']);
    			else if($item['pubdate'] != "") $date = strtotime($item['pubdate']);	// RSS 2.0
    			else $date = time();
    			$post['post_date'] = date('Y-m-d H:i:s', $date);
    
    			// Post status
    			$post['post_status'] = 'publish';
    
    			// Attribution
    			if(get_option('wp_autoblog_attribution') == 1){
    				if($item['author'] != "") $author = $item['author'];
    				else if($item['dc']['creator'] != "") $author = $item['dc']['creator'];
    				else if($item['author_name'] != "") $author = $item['author_name'];
    				else if($item['source'] != "") $author = $item['source'];
    				else if($item['dc']['contributor'] != "") $author = $item['dc']['contributor'];
    
    				// if there is no author, try two things:
    				if($author == "") $author = $rss->channel['title'];
    				if($author == "") $author = 'Unknown';
    
    				$author = strip_tags(trim($author));
    
    				$post['post_content'] .= '<p>';
    				if($author != ""){
    					$post['post_content'] .= ' Read the full post by <em><a href="' . htmlentities(strip_tags(trim($item['link']))) . '" title="' . htmlentities($post['title']) . '">' . htmlentities($author) . '</a></em>';
    					$post['post_content'] .= '';
    				} else {
    					$post['post_content'] .= '';
    				}
    				$post['post_content'] .= '</p>';
    			}

    If someone can let me know what I need to do to modify this code, that wold be great. Thanks.

  2. binh
    Member
    Posted 15 years ago #

    This is not the first time I heard about WP-Autoblog. But I couldn't find where to download it, yet.

    Did you try wp-o-matic? I'm testing it out on my CNTT blog. If you have tried, or after trying it, could you tell me if this wp-autoblog better than wp-o-matic?

  3. bwinn
    Member
    Posted 15 years ago #

    Wp O Matic Didnt work for me... Can anyone help me with the above code? Thanks

  4. joreg
    Member
    Posted 15 years ago #

    After saving the post to the DB add a line to update the guid , like this:

    $wpdb->query ("UPDATE $wpdb->posts SET guid='". htmlentities(strip_tags(trim($item['link']))) ."' WHERE post_title = '" . apply_filters('title_save_pre', $post['post_title']) . "'");

    Maybe you need to check if you ahve a $post(array), my autblog is very costumized.

About this Topic