Plugin articles similaires thumbnails
-
Bonjour,
[b]Ma configuration WP actuelle[/b]
[b]- Version de WordPress[/b] :2.7
[b]- Thème utilisé[/b] : blogtube[b]- Adresse du site[/b] : http://www.videosdunet.fr
[b]Problème(s) rencontré(s) :[/b]
Bonsoir,J’ai trouvé un plugin qui m’affiche des articles au hasard quand je fait appel a lui. En plus de ça, il me crée automatiquement une miniature d’une image de l’article qu’il utilise pour mettre a coté du lien de l’article au hasard.
Moi sur mon site, je crée un champ personnalisé à chaque nouvel article où je rajoute l’adresse d’une miniature. Ce champ je l’appelle » thumbs «
Je voudrais en fait que ce plugin, au lieu de créer une image, il utilise directement la mienne en faisant appel au champ personnalisé « thumbs » que j’ai crée
Je vous laisse le code du plugin que je voudrais modifier :
[code]<?php
/*
Plugin Name: Related Posts Thumbnails
Plugin URI: http://www.papygeek.com/wordpress/wordpress-plugin-articles-lies-miniatures
Description: Retourne une liste des articles liés sous forme de miniatures. Basé sur Related Entries.
Version: 2.02 + 404
Author: PapyGeek
Version: 0.1
Author URI: http://www.papygeek.com/
*/// Begin setup
global $ran_plugin;
if (! isset($ran_plugin)) {
$ran_plugin = true;
if (isset($_REQUEST['setup'])) // Setup is initiated using related-posts.php?setup
{
global $file_path, $user_level;
require_once(dirname(__FILE__).'/../../' .'wp-config.php');
get_currentuserinfo();
if ($user_level < 8)
die ("Sorry, you must be at least a level 8 user."); // Make sure that user has sufficient priveleges// SQL query to setup the actual full-text index
require(dirname(__FILE__).'/../../' .'wp-config.php');
global $table_prefix;
$connexion = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Can't connect.
".mysql_error());
$dbconnexion = mysql_select_db(DB_NAME, $connexion);if (!$dbconnexion)
{
echo mysql_error();
die();
}
$sql_run = 'ALTER TABLE'.$table_prefix.'postsADD FULLTEXTpost_related(post_name,'
. 'post_content)';
$sql_result = mysql_query($sql_run);if ($sql_result)
echo ("Congratulations! Full text index was created successfully!");else
echo (" Something went wrong. Please check the instructions on how to setup the full text index manually.");
}
}// End setup
// Related Posts - Utilise Post Thumbs Revisited - http://www.alakhnor.com/post-thumb
function related_posts_thumbnails($limit=5, $len=10, $before_title = '', $after_title = '', $before_post = '', $after_post = '', $show_pass_post = false, $show_excerpt = false) {
global $wpdb, $post;
// Get option values from the options page
$limit = get_option('limit');
$len = get_option('len');
$before_title = stripslashes(get_option('before_title'));
$after_title = stripslashes(get_option('after_title'));
$before_post = stripslashes(get_option('before_post'));
$after_post = stripslashes(get_option('after_post'));
$show_pass_post = get_option('show_pass_post');
$show_excerpt = get_option('show_excerpt');// Fetch keywords
$postcustom = get_post_custom_values('keyword');
if (!empty($postcustom)) {
$values = array_map('trim', $postcustom);
$terms = implode($values, ' ');
} else {
$terms = str_replace('-', ' ', $post->post_name);
}// Make sure the post is not from the future
$time_difference = get_settings('gmt_offset');
$now = gmdate("Y-m-d H:i:s",(time()+($time_difference*3600)));// Primary SQL query
$sql = "SELECT ID, post_title,"
. "MATCH (post_name, post_content) "
. "AGAINST ('$terms') AS score "
. "FROM $wpdb->posts WHERE "
. "MATCH (post_name, post_content) "
. "AGAINST ('$terms') "
. "AND post_date <= '$now' "
. "AND (post_status IN ( 'publish', 'static' ) && ID != '$post->ID') ";
if ($show_pass_post=='false') { $sql .= "AND post_password ='' "; }
$sql .= "ORDER BY score DESC LIMIT $limit";
$results = $wpdb->get_results($sql);
$output = '';
if ( ! $results) {
//echo $before_title.'Aucun article lié - Articles au hasard :'.$after_title;
$sql2 = "SELECT ID, post_title"
. " FROM $wpdb->posts WHERE "
. "post_date <= '$now' "
. "AND (post_status IN ( 'publish', 'static' ) && ID != '$post->ID') ";
if ($show_pass_post=='false') { $sql2 .= "AND post_password ='' "; }
$sql2 .= "ORDER BY RAND() LIMIT $limit";
$results = $wpdb->get_results($sql2);
}
foreach ($results as $key => $result) {
if ( function_exists('the_thumb') ) {
global $PTRevisited;$array = $PTRevisited->GetPostData($result->ID);
$p = new pt_post_thumbnail($array);
}
$title = stripslashes(apply_filters('the_title', $result->post_title));
$permalink = get_permalink($result->ID);
$indice=$key+1;
$output1 .= $before_title . "<li id="relatedpics-$indice" onmouseover="document.getElementById('relatedlinks-$indice').className = 'highlited'; document.getElementById('relatedpics-$indice').className = 'highlited';" onmouseout="document.getElementById('relatedlinks-$indice').className = ''; document.getElementById('relatedpics-$indice').className =''; ">" . '' . '<img src="' . $p->thumb_url . '" alt="' . $title . '" />
<div class="thumbNumber">' . $indice . '</div>' . $after_title . "n";
$output2 .= $before_title . "<li id="relatedlinks-$indice" onmouseover="document.getElementById('relatedlinks-$indice').className = 'highlited'; document.getElementById('relatedpics-$indice').className ='highlited';" onmouseout="document.getElementById('relatedlinks-$indice').className = ''; document.getElementById('relatedpics-$indice').className ='';">" . '' . $title . '' . $after_title;
}
echo '<ul class="relatedpics">' . $output1 . "
n";
echo '<ol class="relatedlinks">' . $output2 . "n";
}// Related Posts V2 - Utilise les vignettes intégrées de WordPress > 2.6 (Attachments)
function related_posts_thumbnails_v2($limit=5, $len=10, $before_title = '', $after_title = '', $before_post = '', $after_post = '', $show_pass_post = false, $show_excerpt = false) {
global $wpdb, $post;
// Get option values from the options page
$limit = get_option('limit');
$len = get_option('len');
$before_title = stripslashes(get_option('before_title'));
$after_title = stripslashes(get_option('after_title'));
$before_post = stripslashes(get_option('before_post'));
$after_post = stripslashes(get_option('after_post'));
$show_pass_post = get_option('show_pass_post');
$show_excerpt = get_option('show_excerpt');// Fetch keywords
$postcustom = get_post_custom_values('keyword');
if (!empty($postcustom)) {
$values = array_map('trim', $postcustom);
$terms = implode($values, ' ');
} else {
$terms = str_replace('-', ' ', $post->post_name);
}// Make sure the post is not from the future
$time_difference = get_settings('gmt_offset');
$now = gmdate("Y-m-d H:i:s",(time()+($time_difference*3600)));// Primary SQL query
$sql = "SELECT ID, post_title,"
. "MATCH (post_name, post_content) "
. "AGAINST ('$terms') AS score "
. "FROM $wpdb->posts WHERE "
. "MATCH (post_name, post_content) "
. "AGAINST ('$terms') "
. "AND post_date <= '$now' "
. "AND (post_status IN ( 'publish', 'static' ) && ID != '$post->ID') ";
if ($show_pass_post=='false') { $sql .= "AND post_password ='' "; }
$sql .= "ORDER BY score DESC LIMIT $limit";
$results = $wpdb->get_results($sql);
$output = '';
if ( ! $results) {
//echo $before_title.'Aucun article lié - Articles au hasard :'.$after_title;
$sql2 = "SELECT ID, post_title"
. " FROM $wpdb->posts WHERE "
. "post_date <= '$now' "
. "AND (post_status IN ( 'publish', 'static' ) && ID != '$post->ID') ";
if ($show_pass_post=='false') { $sql2 .= "AND post_password ='' "; }
$sql2 .= "ORDER BY RAND() LIMIT $limit";
$results = $wpdb->get_results($sql2);
}
foreach ($results as $key => $result) {
$files = get_children("post_parent=" . $result->ID . "&post_type=attachment&post_mime_type=image");
$thumb = null;
if($files){
$keys = array_keys($files);
$num=$keys[0];
$thumb = wp_get_attachment_thumb_url($num);
}
if (empty($thumb)) $thumb = "http://www.papygeek.com/wp-content/uploads/pth/thumb-defaultpp.jpg";
$title = stripslashes(apply_filters('the_title', $result->post_title));
$permalink = get_permalink($result->ID);
$indice=$key+1;
$output1 .= $before_title . "<li id="relatedpics-$indice" onmouseover="document.getElementById('relatedlinks-$indice').className = 'highlited'; document.getElementById('relatedpics-$indice').className = 'highlited';" onmouseout="document.getElementById('relatedlinks-$indice').className = ''; document.getElementById('relatedpics-$indice').className =''; ">" . '' . '<img height="60" width="90" src="' . $thumb . '" alt="' . $title . '" />
<div class="thumbNumber">' . $indice . '</div>' . $after_title . "n";
$output2 .= $before_title . "<li id="relatedlinks-$indice" onmouseover="document.getElementById('relatedlinks-$indice').className = 'highlited'; document.getElementById('relatedpics-$indice').className ='highlited';" onmouseout="document.getElementById('relatedlinks-$indice').className = ''; document.getElementById('relatedpics-$indice').className ='';">" . '' . $title . '' . $after_title;
}
echo '<ul class="relatedpics">' . $output1 . "
n";
echo '<ol class="relatedlinks">' . $output2 . "n";
}// Related Posts 404 - Utilise Post Thumbs Revisited pour les pages d'erreur 404 - http://www.alakhnor.com/post-thumb
function related_posts_thumbnails_404($limit=5, $len=10, $before_title = '', $after_title = '', $before_post = '', $after_post = '', $show_pass_post = false, $show_excerpt = false) {
global $wpdb, $post;
if ( (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['SERVER_ADDR'] != $_SERVER['REMOTE_ADDR']) || !isset($_SERVER['REMOTE_ADDR']) ) {
//$limit = get_option('limit');
$len = get_option('len');
$before_title = stripslashes(get_option('before_title'));
$after_title = stripslashes(get_option('after_title'));
$before_post = stripslashes(get_option('before_post'));
$after_post = stripslashes(get_option('after_post'));
$show_pass_post = get_option('show_pass_post');
$show_excerpt = get_option('show_excerpt');$search_term = $_SERVER['REQUEST_URI'];
$search = array ('@[/]+@', '@(..*)@', '@[-]+@', '@[_]+@', '@[s]+@', '@archives@','@(?.*)@','/d/');
$replace = array (' ', '', ' ', ' ', ' ', '', '','');
$search_term = preg_replace($search, $replace, $search_term);
$search_term = trim($search_term);
$terms = $search_term;$time_difference = get_settings('gmt_offset');
$now = gmdate("Y-m-d H:i:s",(time()+($time_difference*3600)));// Primary SQL query
$sql = "SELECT ID, post_title,"
. "MATCH (post_name, post_content) "
. "AGAINST ('$terms') AS score "
. "FROM $wpdb->posts WHERE "
. "MATCH (post_name, post_content) "
. "AGAINST ('$terms') "
. "AND post_date <= '$now' "
. "AND (post_status IN ( 'publish', 'static' ) && ID != '$post->ID') ";
if ($show_pass_post=='false') { $sql .= "AND post_password ='' "; }
$sql .= "ORDER BY score DESC LIMIT $limit";
$results = $wpdb->get_results($sql);
$output = '';
if ($results) {
foreach ($results as $key => $result) {
if ( function_exists('the_thumb') ) {
global $PTRevisited;$array = $PTRevisited->GetPostData($result->ID);
$p = new pt_post_thumbnail($array);
}
$title = stripslashes(apply_filters('the_title', $result->post_title));
$permalink = get_permalink($result->ID);
$indice=$key+1;
$output1 .= $before_title . "<li id="relatedpics-$indice" onmouseover="document.getElementById('relatedlinks-$indice').className = 'highlited'; document.getElementById('relatedpics-$indice').className = 'highlited';" onmouseout="document.getElementById('relatedlinks-$indice').className = ''; document.getElementById('relatedpics-$indice').className =''; ">" . '' . '<img src="' . $p->thumb_url . '" alt="' . $title . '" />
<div class="thumbNumber">' . $indice . '</div>' . $after_title . "n";
$output2 .= $before_title . "<li id="relatedlinks-$indice" onmouseover="document.getElementById('relatedlinks-$indice').className = 'highlited'; document.getElementById('relatedpics-$indice').className ='highlited';" onmouseout="document.getElementById('relatedlinks-$indice').className = ''; document.getElementById('relatedpics-$indice').className ='';">" . '' . $title . '' . $after_title;
if ($show_excerpt=='true') {
$words=split(" ",$post_content);
$post_strip = join(" ", array_slice($words,0,$len));
$output2 .= $before_post . $post_strip . $after_post;
}
}
echo '<ul class="relatedpics">' . $output1 . "
n";
echo '<ol class="relatedlinks">' . $output2 . "n";
} else {
echo $before_title.'Fuzzy ...'.$after_title;
}
} else {
echo $before_title.'Fuzzy ...'.$after_title;
}
}// Related Posts Random - Utilise Post Thumbs Revisited pour afficher des articles liés au hasard - http://www.alakhnor.com/post-thumb
function related_posts_thumbnails_random($limit=5, $len=10, $before_title = '', $after_title = '', $before_post = '', $after_post = '', $show_pass_post = false, $show_excerpt = false) {
global $wpdb, $post;
//$limit = get_option('limit');
$len = get_option('len');
$before_title = stripslashes(get_option('before_title'));
$after_title = stripslashes(get_option('after_title'));
$before_post = stripslashes(get_option('before_post'));
$after_post = stripslashes(get_option('after_post'));
$show_pass_post = get_option('show_pass_post');
$show_excerpt = get_option('show_excerpt');$time_difference = get_settings('gmt_offset');
$now = gmdate("Y-m-d H:i:s",(time()+($time_difference*3600)));// Primary SQL query
$sql = "SELECT ID, post_title"
. " FROM $wpdb->posts WHERE "
. "post_date <= '$now' "
. " AND post_status IN ( 'publish', 'static' ) "
. " AND post_password ='' "
. "ORDER BY RAND() DESC LIMIT $limit";
$results = $wpdb->get_results($sql);
$output = '';
if ($results) {
foreach ($results as $key => $result) {
if ( function_exists('the_thumb') ) {
global $PTRevisited;$array = $PTRevisited->GetPostData($result->ID);
$p = new pt_post_thumbnail($array);
}
$title = stripslashes(apply_filters('the_title', $result->post_title));
$permalink = get_permalink($result->ID);
$indice=$key+1;
$output1 .= $before_title . "<li id="relatedpics-$indice" onmouseover="document.getElementById('relatedlinks-$indice').className = 'highlited'; document.getElementById('relatedpics-$indice').className = 'highlited';" onmouseout="document.getElementById('relatedlinks-$indice').className = ''; document.getElementById('relatedpics-$indice').className =''; ">" . '' . '<img src="' . $p->thumb_url . '" alt="' . $title . '" />
<div class="thumbNumber">' . $indice . '</div>' . $after_title . "n";
$output2 .= $before_title . "<li id="relatedlinks-$indice" onmouseover="document.getElementById('relatedlinks-$indice').className = 'highlited'; document.getElementById('relatedpics-$indice').className ='highlited';" onmouseout="document.getElementById('relatedlinks-$indice').className = ''; document.getElementById('relatedpics-$indice').className ='';">" . '' . $title . '' . $after_title;
if ($show_excerpt=='true') {
$words=split(" ",$post_content);
$post_strip = join(" ", array_slice($words,0,$len));
$output2 .= $before_post . $post_strip . $after_post;
}
}
echo '<ul class="relatedpics">' . $output1 . "
n";
echo '<ol class="relatedlinks">' . $output2 . "n";
} else {
echo $before_title.'Fuzzy ...'.$after_title;
}
}// End Related Posts
// Begin Keywords
function find_keywords($id) {
global $wpdb;
$content = $wpdb->get_var("SELECT post_content FROM $wpdb->posts WHERE ID = '$id'");
if (preg_match_all('/<!--kw=([sS]*?)-->/i', $content, $matches, PREG_SET_ORDER)) {
$test = $wpdb->get_var("SELECT meta_value FROM $wpdb->postmeta WHERE post_id = '$id' AND meta_key = 'keyword'");
if (!empty($test)) {
$output = explode(' ', $test);
} else {
$output = array();
}
foreach($matches as $match) {
$output = array_merge($output, explode(' ', $match[1]));
}
$output = array_unique($output);
$keywords = implode(' ', $output);
if (!empty($test)) {
$results= $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$keywords' WHERE post_id = '$id' AND meta_key = 'keyword'");
} else {
$results = $wpdb->query("INSERT INTO $wpdb->postmeta (post_id,meta_key,meta_value) VALUES ('$id', 'keyword', '$keywords')");
}
$content = format_to_post(balanceTags(preg_replace("/<!--kw=([sS]*?)-->/i", "<!--$1-->", $content)));
$results = $wpdb->query("UPDATE $wpdb->posts SET post_content = '$content' WHERE ID = '$id'");
}
return $id;
}// End Keywords
// Begin Related Posts Options
function rp_subpanel() {
if (isset($_POST['update_rp'])) {
$option_limit = $_POST['limit'];
$option_len = $_POST['len'];
$option_before_title = $_POST['before_title'];
$option_after_title = $_POST['after_title'];
$option_before_post = $_POST['before_post'];
$option_after_post = $_POST['after_post'];
$option_show_pass_post = $_POST['show_pass_post'];
$option_show_excerpt = $_POST['show_excerpt'];
update_option('limit', $option_limit);
update_option('len', $option_len);
update_option('before_title', $option_before_title);
update_option('after_title', $option_after_title);
update_option('before_post', $option_before_post);
update_option('after_post', $option_after_post);
update_option('show_pass_post', $option_show_pass_post);
update_option('show_excerpt', $option_show_excerpt);
?> <div class="updated"><p>Options saved!</p></div> <?php
}
?><div class="wrap">
<h2>Related Posts Options</h2>
<form method="post">
<fieldset class="options">
<table>
<tr>
<td><label for="limit">How many related posts would you like to show?</label>:</td>
<td><input name="limit" type="text" id="limit" value="<?php echo get_option('limit'); ?>" size="2" /></td>
</tr>
<tr>
<td><label for="before_title">Before</label> / <label for="after_title">After (Post Title) </label>:</td>
<td><input name="before_title" type="text" id="before_title" value="<?php echo htmlspecialchars(stripslashes(get_option('before_title'))); ?>" size="10" /> / <input name="after_title" type="text" id="after_title" value="<?php echo htmlspecialchars(stripslashes(get_option('after_title'))); ?>" size="10" /><small> For example:- or <dl></dl></small>
</td>
</tr>
<tr>
<td>Show excerpt?</td>
<td>
<select name="show_excerpt" id="show_excerpt">
<option <?php if(get_option('show_excerpt') == 'false') { echo 'selected'; } ?> value="false">False</option>
<option <?php if(get_option('show_excerpt') == 'true') { echo 'selected'; } ?> value="true">True</option>
</select>
</td>
</tr>
<tr>
<td><label for="len">Excerpt length (No. of words):</label></td>
<td><input name="len" type="text" id="len" value="<?php echo get_option('len'); ?>" size="2" />
</tr>
<tr>
<td><label for="before_post">Before</label> / <label for="after_post">After</label> (Excerpt):</td>
<td><input name="before_post" type="text" id="before_post" value="<?php echo htmlspecialchars(stripslashes(get_option('before_post'))); ?>" size="10" /> / <input name="after_post" type="text" id="after_post" value="<?php echo htmlspecialchars(stripslashes(get_option('after_post'))); ?>" size="10" /><small> For example:- or <dl></dl></small>
</td>
</tr>
<tr>
<td><label for="show_pass_post">Show password protected posts?</label></td>
<td>
<select name="show_pass_post" id="show_pass_post">
<option <?php if(get_option('show_pass_post') == 'false') { echo 'selected'; } ?> value="false">False</option>
<option <?php if(get_option('show_pass_post') == 'true') { echo 'selected'; } ?> value="true">True</option>
</select>
</td>
</tr>
</table>
</fieldset><p><div class="submit"><input type="submit" name="update_rp" value="<?php _e('Save!', 'update_rp') ?>" style="font-weight:bold;" /></div></p>
</form>
</div>
<div class="wrap">
<h2>SQL Index Table Setup</h2>
<p>If this is your first time installing this plugin you will have to run this script (opens a new window) in order to create the index table required by the plugin. If this fails, please refer to the readme on how to create it manually.</p></div>
<?php }
// End Related Posts Options
function rp_admin_menu() {
if (function_exists('add_submenu_page')) {
add_submenu_page('plugins.php', __('Related Posts Options'), __('Related Posts Options'), 1, __FILE__, 'rp_subpanel');
}
}add_action('edit_post', 'find_keywords', 1);
// add_action('publish_post', 'find_keywords', 1);
add_action('admin_menu', 'rp_admin_menu');?>[/code]
[b]Merci à tous ceux qui pourront m’aider !!![/b]L’adresse du blog concerné est (visible uniquement pour les utilisateurs connectés).
-
The blog you specified at http://www.videosdunet.fr does not appear to be hosted at WordPress.com.
This support forum is for WordPress.com hosted blogs only. If you have a self-hosted WordPress blog you need to seek help at the WordPress.org forums, not here.
If you don’t understand the difference, you may find this information helpful.
- Le sujet ‘Plugin articles similaires thumbnails’ est fermé aux nouvelles réponses.