<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Wordpress related posts with thumbs]]></title><description><![CDATA[<p dir="auto">Ciao a tutti!<br />
Ho installato questo plugin che permette di estrarre l'anteprima della prima immagine inserita in un post e affiancarla ad esso quando viene listato tra gli articoli correlati.</p>
<p dir="auto">A me però servirebbe estrarre, solo dove presente, la seconda immagine ed ho provato ad utilizzare il preg_match_all come suggerito sul sito del plugin ma non va. Suggerimenti?</p>
<p dir="auto">Questo è il codice originale</p>
<pre><code>//inizio formattazione output
    $all_post_text = $related_post-&gt;post_content;
    // estrazione della prima immagine
    $first_img=false;
    $resized_url=false;
    if ( preg_match  ( '/resize.php\?url=(.*?)&amp;/i',$all_post_text,  $matches)){
                    
            $first_img = $matches[1];
            $first_img = urldecode ($first_img);
            $crypt = new encryption_class;
            $dimension_encoded = urlencode ($crypt-&gt;encrypt($zkey,$wp_rp_thumb_size));
            $imgurl_encoded = urlencode ($crypt-&gt;encrypt($zkey,$first_img));
            $resized_url = $blogurl."/wp-content/plugins/WPRPT/resize.php?size=".$dimension_encoded."&amp;url=".$imgurl_encoded;
    }
    elseif ( preg_match  ( '/&lt;img.*?src=["\'](.*?)["\'].*?&gt;/i',$all_post_text,  $matches)){
            $first_img = $matches[1];
            $crypt = new encryption_class;
            $dimension_encoded = urlencode ($crypt-&gt;encrypt($zkey,$wp_rp_thumb_size));
            $imgurl_encoded = urlencode ($crypt-&gt;encrypt($zkey,$first_img));
            $resized_url = $blogurl."/wp-content/plugins/WPRPT/resize.php?size=".$dimension_encoded."&amp;url=".$imgurl_encoded;
    } else {}
    $text_content = strip_tags($related_post-&gt;post_content); // toglie i tag html dal testo
    $text_content = truncateText($text_content,150,'...',false,true); //numero di caratteri da mostrare del testo
    $attachment_id = $wpdb-&gt;get_var("SELECT ID FROM $wpdb-&gt;posts WHERE post_parent = '$related_post-&gt;ID' AND post_status = 'inherit' AND post_type='attachment' ORDER BY post_date DESC LIMIT 1");
    if ($resized_url) {
      $output .= '  &lt;div class="img_related_post"&gt;&lt;img src="'.$resized_url.'"/&gt;&lt;/div&gt;'."\n";
    } else {
      $output .= '  &lt;div class="img_related_post"&gt;'.get_attachment_icon($attachment_id).'&lt;/div&gt;'."\n";
    }
    $output .=  '  &lt;div class="text_related_post"&gt;'."\n".'    &lt;a href="'.get_permalink($related_post-&gt;ID).'" title="'.wptexturize($related_post-&gt;post_title).'"&gt;'.wptexturize($related_post-&gt;post_title)."&lt;/a&gt;\n";
    if ($show_date){
      $dateformat = get_option('date_format');
      $output .=   "    &lt;span class='publi_related_post'&gt;Pubblicato il:&lt;/span&gt; &lt;span class='publi_related_post_date'&gt;".mysql2date($dateformat, $related_post-&gt;post_date) . "&lt;/span&gt;\n";
    }
    if ($show_comments_count){
      $output .=  "    &lt;span class='comments_related_post'&gt;Commenti: " . $related_post-&gt;comment_count . "&lt;/span&gt;\n";
    }
    $output .=  "  &lt;/div&gt;\n";
  }
  $output = '&lt;ul class="related_post"&gt;' . "\n". $output . "\n".'&lt;/ul&gt;';
  //fine formattazione
```e questo la soluzione proposta che non funziona
</code></pre>
<p dir="auto">if ( preg_match_all  ( '//i',$all_post_text,  $matches)){</p>
<pre><code>                $first_img = $matches[1][2];
</code></pre>
<pre><code></code></pre>
]]></description><link>https://connect.gt/topic/99573/wordpress-related-posts-with-thumbs</link><generator>RSS for Node</generator><lastBuildDate>Wed, 10 Jun 2026 06:18:28 GMT</lastBuildDate><atom:link href="https://connect.gt/topic/99573.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 16 Apr 2009 12:53:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Wordpress related posts with thumbs on Mon, 20 Apr 2009 20:33:44 GMT]]></title><description><![CDATA[<p dir="auto">nessuno che può aiutarmi?</p>
]]></description><link>https://connect.gt/post/824586</link><guid isPermaLink="true">https://connect.gt/post/824586</guid><dc:creator><![CDATA[stef84]]></dc:creator><pubDate>Mon, 20 Apr 2009 20:33:44 GMT</pubDate></item></channel></rss>