Grazie al tuo prezioso aiuto sono riuscito a risolvere il problema del "Link".
Ho aggiunto il codice css nel mio file style.css, il problema è che non sò dove inserire il codice php. Sappi che quello riportato precedentemente era solo un estratto di questo codice:
Codice PHP:
<?php //preso da WP Codex function postimage($size="thumbnail") { if ( $images = get_children(array( 'post_parent' => get_the_ID(), 'post_type' => 'attachment', 'numberposts' => 1, 'post_mime_type' => 'image',))) { foreach( $images as $image ) { $attachmenturl=wp_get_attachment_url($image->ID); $attachmentimage=wp_get_attachment_image( $image->ID, $size ); echo '[url="'.$attachmenturl.'"]'.$attachmentimage.'[/url]'; break; //una sola immagine stampata } } else { return; } } //Anteprima Immagine in fase di condivisione function set_default_image(){ global $post; $image = str_img_src($post->post_content); if($image != ""){ echo '<link rel="image_src" href="'. $image . '" />' . "\n"; } } add_action('wp_head', 'set_default_image'); function str_img_src($html) { if (strpos($html, '<img') !== false) { $imgsrc_regex = '#<\s*img [^\>]*src\s*=\s*(["\'])(.*?)\1#im'; preg_match($imgsrc_regex, $html, $matches); unset($imgsrc_regex); unset($html); if (is_array($matches) && !empty($matches)) { return $matches[2]; } else { return false; } } else { return false; } } function the_content_limit($max_char, $more_link_text = '(more...)', $stripteaser = 0, $more_file = '') { $content = get_the_content($more_link_text, $stripteaser, $more_file); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); $content = strip_tags($content); if (strlen($_GET['p']) > 0) { echo "
"; echo $content; echo "[url='"; the_permalink(); echo "']"."Read More →[/url]"; echo "</p>"; } else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) { $content = substr($content, 0, $espacio); $content = $content; echo "
"; echo $content; echo "..."; echo "[url='"; the_permalink(); echo "']".$more_link_text."[/url]"; echo "</p>"; } else { echo "
"; echo $content; echo "[url='"; the_permalink(); echo "']"."Read More →[/url]"; echo "</p>"; } } function bdw_get_images($post, $tipo) { // Get the post ID $iPostID = $post->ID; // Get images for this post $arrImages =& get_children('post_type=attachment&post_mime_type=image&post_parent=' . $iPostID ); // If images exist for this page if($arrImages) { // Get array keys representing attached image numbers $arrKeys = array_keys($arrImages); /******BEGIN BUBBLE SORT BY MENU ORDER************ // Put all image objects into new array with standard numeric keys (new array only needed while we sort the keys) foreach($arrImages as $oImage) { $arrNewImages[] = $oImage; } // Bubble sort image object array by menu_order TODO: Turn this into std "sort-by" function in functions.php for($i = 0; $i < sizeof($arrNewImages) - 1; $i++) { for($j = 0; $j < sizeof($arrNewImages) - 1; $j++) { if((int)$arrNewImages[$j]->menu_order > (int)$arrNewImages[$j + 1]->menu_order) { $oTemp = $arrNewImages[$j]; $arrNewImages[$j] = $arrNewImages[$j + 1]; $arrNewImages[$j + 1] = $oTemp; } } } // Reset arrKeys array $arrKeys = array(); // Replace arrKeys with newly sorted object ids foreach($arrNewImages as $oNewImage) { $arrKeys[] = $oNewImage->ID; } ******END BUBBLE SORT BY MENU ORDER**************/ // Get the first image attachment $iNum = $arrKeys[0]; if ($tipo=="small" || $tipo=="thumbnail") { // Get the thumbnail url for the attachment $sUrl = wp_get_attachment_thumb_url($iNum); } else { // FULL SIZE IMAGE INSTEAD OF THE THUMBNAIL $sUrl = wp_get_attachment_url($iNum); } //$dim = ''; //if ($tipo=="thumbnail") { $dim = 'width="150" height="150"'; } //if ($tipo=="small") { $dim = 'width="65" height="65"'; } // Build the <img> string $sImgString = '[url="' . get_permalink() . '"]' . '[img]' . $sUrl . '[/img]' . '[/url]'; // Print the image echo $sImgString; } }
Quale vantaggio ottengo se cambio il codice attuale con quello suggerito da te ?