-
Cambiare tema ma...
Vorrei passare da un tema all altro ma ci sono 2 problemi che mi trattengono nel farlo...
1 - Nel tema iniziale [piu tema blog] non c'era bisogno di mettere l immagine in evidenza per darne l anteprima nell articolo! In quello nuovo dovrei rimpostarla a tutti i 200 articoli! Come posso risolvere? C'è qualche stringa da cambiare? in modo che ogni immagine è automaticamente in evidenza...
2 - Attraverso la scrittura [ad code=x align=center] inserivo i banner negli articoli ma adesso col nuovo non esce piu il banner ma mi uscirebbe la scritta "[ad code=x align=center]". Come risolvo anche questo senza cancellare ste voci in 200 articoli?
URGENTE :S
-
1. Si può fare, inserivi l'immagine dentro i campi personalizzati oppure la rilevava in automatico?
2. Quello bisogna vedere gli script utilizzati dal vecchio template...
-
1- In automatico
2 - Consigli?
-
- C'è uno script che preleva in automatico un'immagine all'interno dell'articolo e non dalle immagini in evidenza. Qual è il tema e che funzione utilizza? Si potrebbe fare qualche modifica.
- Potresti eliminare tutti i codici "[ad code=x align=center]" presenti negli articoli direttamente eseguendo un comando (replace) nel database e poi imposti i banner pubblicitari in un altro modo.
-
- Ora uso Mystique 2.4.2 di digitalnature
vorrei passare a Avenue 1.1 di Theme Sector
- Come si usa quel comando? Scusa l ignoranza...
-
Prova a dare un'occhiata qui http://wordpress.altervista.org/visu...ne-di-un-post/. L'ho scritto apposta per casi come il tuo. Te la dovresti cavare con una modifica non troppo pesante sul nuovo tema.
-
Ho provato ma niente... Magari se mi dici meglio dove modificare
- index.php
Codice PHP:
<?php get_header(); ?>
<!-- BEGIN MAIN -->
<div id="main">
<?php if(get_option('pyre_featured_tags')): ?>
<?php
$post_types = get_post_types();
unset($post_types['page'], $post_types['attachment'], $post_types['revision'], $post_types['nav_menu_item']);
$featured_posts = new WP_Query(array(
'post_type' => $post_types,
'showposts' => 5,
'tag' => get_option('pyre_featured_tags')
));
?>
<!-- BEGIN WRAPPER-FEATURED -->
<div id="wrapper-featured">
<div id="wrapper-slides">
<div id="slider" class="nivoSlider">
<?php while($featured_posts->have_posts()): $featured_posts->the_post(); ?>
<?php if(has_post_thumbnail()): ?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'featured-image'); ?>
<?php $image_thumb = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'featured-image-thumb'); ?>
<a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><img src="<?php echo $image[0]; ?>" alt="<?php the_title(); ?>" title="#htmlcaption_<?php the_ID(); ?>" rel="<?php echo $image_thumb[0]; ?>" width='516' height='340' /></a>
<?php else: ?>
<a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><img src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php bloginfo('template_directory'); ?>/images/thumbnail.png&w=516&h=340" alt="<?php the_title(); ?>" title="#htmlcaption_<?php the_ID(); ?>" rel="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php bloginfo('template_directory'); ?>/images/thumbnail.png&w=70&h=60" width='516' height='340' /></a>
<?php endif; ?>
<?php endwhile; ?>
</div>
<?php while($featured_posts->have_posts()): $featured_posts->the_post(); ?>
<div class="nivo-html-caption" id="htmlcaption_<?php the_ID(); ?>">
<h1><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><?php the_title(); ?></a></h1>
<p><?php echo string_limit_words(get_the_excerpt(), 15); ?> <span class="block-arrows"><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>»</a></span></p>
</div>
<?php endwhile; ?>
</div>
</div>
<!-- END WRAPPER-FEATURED -->
<?php endif; ?>
<!-- BEGIN HOMEPAGE BLOCKS -->
<?php if(get_option('pyre_homepage_style') == 'magazine'): ?>
<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Homepage')): ?>
<div class="block full">
<h3><?php _e('Recent Posts'); ?> <span class="arrows">»</span></h3>
<?php
$recent_posts = new WP_Query(array(
'showposts' => 4,
));
?>
<?php
$big_count = round(4 / 4);
if(!$big_count) { $big_count = 1; }
?>
<?php $counter = 1; while($recent_posts->have_posts()): $recent_posts->the_post(); ?>
<?php
if(has_post_format('video') || has_post_format('audio') || has_post_format('gallery')) {
$icon = '<span class="' . get_post_format($post->ID) . '-icon"></span>';
} else {
$icon = '';
}
?>
<?php if($counter <= $big_count): ?>
<div class="block-item-big">
<?php if(has_post_thumbnail()): ?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'widget-image'); ?>
<div class="block-image"><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><img src="<?php echo $image[0]; ?>" alt="<?php the_title(); ?>" width='290' height='160' /></a><?php echo $icon; ?></div>
<?php else: ?>
<div class="block-image"><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><img src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php bloginfo('template_directory'); ?>/images/thumbnail.png&w=290&h=160" alt="<?php the_title(); ?>" width='290' height='160' /></a><?php echo $icon; ?></div>
<?php endif; ?>
<h2><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><?php the_title(); ?></a></h2>
<span class="block-meta"><?php the_time('F j, Y'); ?>, <?php comments_popup_link(); ?></span>
</div>
<?php else: ?>
<div class="block-item-small">
<?php if(has_post_thumbnail()): ?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'widget-image-thumb'); ?>
<div class="block-image"><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><img src="<?php echo $image[0]; ?>" alt="<?php the_title(); ?>" width='50' height='50' /></a><?php echo $icon; ?></div>
<?php else: ?>
<div class="block-image"><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><img src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php bloginfo('template_directory'); ?>/images/thumbnail.png&w=60&h=60" alt="<?php the_title(); ?>" width='50' height='50' /></a><?php echo $icon; ?></div>
<?php endif; ?>
<h2><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><?php the_title(); ?></a></h2>
<span class="block-meta"><?php the_time('F j, Y'); ?>, <?php comments_popup_link(); ?></span>
</div>
<?php endif; ?>
<?php $counter++; endwhile; ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if(get_option('pyre_homepage_style') == 'blog'): ?>
<div class="block archive">
<h3>
<?php _e('Recent Posts'); ?>
<span class="arrows">»</span>
</h3>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class('block-item-big'); ?>>
<?php
if(has_post_format('video') || has_post_format('audio') || has_post_format('gallery')) {
$icon = '<span class="' . get_post_format($post->ID) . '-icon"></span>';
} else {
$icon = '';
}
?>
<?php if(has_post_thumbnail()): ?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'widget-image'); ?>
<div class="block-image"><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><img src="<?php echo $image[0]; ?>" alt="<?php the_title(); ?>" width='290' height='160' /></a><?php echo $icon; ?></div>
<?php else: ?>
<div class="block-image"><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><img src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php bloginfo('template_directory'); ?>/images/thumbnail.png&w=290&h=160" alt="<?php the_title(); ?>" width='290' height='160' /></a><?php echo $icon; ?></div>
<?php endif; ?>
<h2><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><?php the_title(); ?></a></h2>
<span class="block-meta">
<span class="heading-author"><?php the_author(); ?></span>
<span class="heading-date"><?php the_time('F j, Y'); ?></span>
<span class="heading-comments"><?php comments_popup_link('0','1','%'); ?></span>
</span>
<p><?php echo string_limit_words(get_the_excerpt(), 34); ?></p><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>' class="readmore"><?php _e('Read More'); ?> <span class="block-arrows">»</span></a>
</div>
<?php endwhile; endif; ?>
<?php kriesi_pagination($pages = '', $range = 2); ?>
</div>
<?php endif; ?>
<!-- END HOMEPAGE BLOCKS -->
</div>
<!-- END MAIN -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
-
- functions.php (questo è gia modificato da me vedi se sta bene....)
Codice PHP:
<?php
function get_related_posts($post_id, $tags = array()) {
$query = new WP_Query();
$post_types = get_post_types();
unset($post_types['page'], $post_types['attachment'], $post_types['revision'], $post_types['nav_menu_item']);
if($tags) {
foreach($tags as $tag) {
$tagsA[] = $tag->term_id;
}
}
$args = wp_parse_args($args, array(
'showposts' => 4,
'post_type' => $post_types,
'post__not_in' => array($post_id),
'tag__in' => $tagsA,
'ignore_sticky_posts' => 1,
));
$query = new WP_Query($args);
return $query;
}
function kriesi_pagination($pages = '', $range = 2)
{
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == '')
{
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages)
{
$pages = 1;
}
}
if(1 != $pages)
{
echo "<div class='pagination'>";
if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'><span class='arrows'>«</span> First</a>";
if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'><span class='arrows'>‹</span> Previous</a>";
for ($i=1; $i <= $pages; $i++)
{
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
{
echo ($paged == $i)? "<span class='current'>".$i."</span>":"<a href='".get_pagenum_link($i)."' class='inactive' >".$i."</a>";
}
}
if ($paged < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($paged + 1)."'>Next <span class='arrows'>›</span></a>";
if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>Last <span class='arrows'>»</span></a>";
echo "</div>\n";
}
}
function string_limit_words($string, $word_limit)
{
$words = explode(' ', $string, ($word_limit + 1));
if(count($words) > $word_limit) {
array_pop($words);
}
return implode(' ', $words);
}
function get_first_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
//seleziono la prima immagine
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i',
$post->post_content, $matches);
$first_img = $matches [1] [0];
//se non c'è un'immagine ne assegno una di default
if(empty($first_img)){
$first_img = "/images/default.jpg";
}
return $first_img;
}
- archives.php
Codice PHP:
<?php get_header(); ?>
<!-- BEGIN MAIN -->
<div id="main">
<div class="block archive">
<h3>
<?php if(is_day()): ?>
<?php printf(__( 'Daily Archives: <span>%s</span>'), get_the_date()); ?>
<?php elseif (is_month()) : ?>
<?php printf(__('Monthly Archives: <span>%s</span>'), get_the_date('F Y')); ?>
<?php elseif (is_year()) : ?>
<?php printf(__('Yearly Archives: <span>%s</span>'), get_the_date('Y')); ?>
<?php else : ?>
<?php _e('Blog Archives'); ?>
<?php endif; ?>
<span class="arrows">»</span>
</h3>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class('block-item-big'); ?>>
<?php
if(has_post_format('video') || has_post_format('audio') || has_post_format('gallery')) {
$icon = '<span class="' . get_post_format($post->ID) . '-icon"></span>';
} else {
$icon = '';
}
?>
<?php if(has_post_thumbnail()): ?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'widget-image'); ?>
<div class="block-image"><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><img src="<?php echo $image[0]; ?>" alt="<?php the_title(); ?>" width='290' height='160' /></a><?php echo $icon; ?></div>
<?php endif; ?>
<h2><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><?php the_title(); ?></a></h2>
<span class="block-meta">
<span class="heading-author"><?php the_author(); ?></span>
<span class="heading-date"><?php the_time('F j, Y'); ?></span>
<span class="heading-comments"><?php comments_popup_link('0','1','%'); ?></span>
</span>
<p><?php echo string_limit_words(get_the_excerpt(), 34); ?></p><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>' class="readmore"><?php _e('Read More'); ?> <span class="block-arrows">»</span></a>
</div>
<?php endwhile; endif; ?>
<?php kriesi_pagination($pages = '', $range = 2); ?>
</div>
</div>
<!-- END MAIN -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Ecco i codici :S
-
Il tuo caso è un po'più complicato per via della presenza di timthumb. Prova a far così:
In index.php cerca le righe (ce n'è più di una)
Codice PHP:
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'widget-image-thumb'); ?>
e sostituisci con:
Codice PHP:
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'widget-image-thumb');
if(is_empty($image)) :
$image = get_first_image();
endif; ?>
Occhio che non ho controllato se ci sono errori di sintassi.
-
Ho provato con F3 e mi ha segnalato solo la presenza di una stringa come quella... Sostituita ma niente... Mannaggia che nervi! Grazie dell aiuto io non so piu come fare :(
-
Ps: e per fare quel comando sul db come faccio?
-