Supporto » Varie ed eventuali » Cambiare “Scritto da” con “a cura di” oppure cancellare solo per una categoria

Stai visualizzando 8 risposte - dal 1 al 8 (di 8 totali)
  • Questa modifica è possibile. Dovresti creare un template per la tua categoria desiderata dove dopo puoi cambiare le parti ceh vuoi. Puoi fare una copia del file category.php e rinominarlo in category-abruzzo.php e fare questa modifica al testo. Qui ci sono più info (in inglese) su come funzionano i template delle categorie: https://codex.wordpress.org/Category_Templates#What_Template_File_is_Used.3F

    Buon lavoro 😉

    Chi ha creato la discussione Stefano82

    (@stefano82)

    Grazie mille per il prezioso aiuto prima di tutto.

    Ho aperto questo file ma non ho trovato quel che cercavo. Ho trovato la scritta da modificare dentro “content.php”, riesco anche a modificarla ma non riesco ancora a farla modificare per una sola categoria.

    ciò potrebbe essere dovuto al fatto che il template è stato creato personalizzato ad hoc da un’agenzia per questo sito. Non sono stato io a crearlo quindi alcune cose ancora non le conosco a fondo.

    A breve posterò il contenuto del codice in questione così fornirò qualche elemento in più su cui discutere.

    Grazie mille per la disponibilità e a presto.

    Chi ha creato la discussione Stefano82

    (@stefano82)

    Ecco il codice

    <div class="post-meta">
    		<span class="posted-by"><?php _ex('Scritto da', 'Post Meta', 'bunyad'); 
    		?>
    			<span class="reviewer" itemprop="author"><?php the_author_posts_link(); ?></span>
    		</span>		
    		 
    		<span class="posted-on"><?php _ex('il', 'Post Meta', 'bunyad'); ?>
    			<span class="dtreviewed">
    				<time class="value-datetime" datetime="<?php echo esc_attr(get_the_time('c')); ?>" itemprop="datePublished"><?php echo esc_html(get_the_date()); ?></time>
    			</span>
    		</span>
    Chi ha creato la discussione Stefano82

    (@stefano82)

    Nessuno sa aiutarmi? Nel file category.php non ci sono gli elementi della categoria che voglio modificare. Anzi! Non c’è praticamente niente. Vi incollo qui il codice se volete.

    <?php
    
    /**
     * Category Template
     * 
     * Sets up the correct loop format to use. Additionally, meta is processed for other
     * layout preferences.
     */
    
    $category = get_category(get_query_var('cat'), false);
    $cat_meta = Bunyad::options()->get('cat_meta_' . $category->term_id);
    
    // no template? fall-back to default template
    if (!$cat_meta OR !$cat_meta['template']) {
    	$cat_meta['template'] = Bunyad::options()->default_cat_template;
    }
    
    /**
     * Select the listing template to use
     */
    if (in_array($cat_meta['template'], array('alt', 'classic'))) {
    	$loop_template = 'loop-' . $cat_meta['template'];
    }
    else {
    	// default to grid template
    	$loop_template = 'loop';
    	
    
    	// set type of loop grid - if using the grid
    	$loop_grid = 2;
    	
    	if ($cat_meta['template'] == 'grid-3') {
    		$loop_grid = 3;
    	}
    	
    	Bunyad::registry()->set('loop_grid', $loop_grid);
    	
    }
    
    // have a sidebar preference?
    if (!empty($cat_meta['sidebar'])) {
    	Bunyad::core()->set_sidebar($cat_meta['sidebar']);
    }
    
    // store variables in registry
    Bunyad::registry()
    	->set('loop_template', $loop_template)
    	->set('listing_class', 'term-wrap-' . $category->term_id);
    
    // render
    get_template_part('archive');
    Moderatore Francesco Di Candia

    (@francescodicandia)

    Ciao, ciò che diceva @sgelob è che devi creare un template ad hoc per la categoria che ti interessa seguendo le informazioni che ci sono a questo link https://codex.wordpress.org/Category_Templates#What_Template_File_is_Used.3F
    Così facendo creerai un template SOLO per quella precisa categoria nel quale potrai modificare le informazioni che ti interessano SOLO per quella categoria.
    F.

    Chi ha creato la discussione Stefano82

    (@stefano82)

    Salve. Grazie per la risposta. Purtroppo pur seguende le istruzioni lette negli articoli che mi avete suggerito ancora non sono riuscito a risolvere il problema.

    Probabilmente le mie difficoltà sono dovute a due cose:

    1-non sono un esperto di php
    2-il template non è standard ma costruito ad hoc da altri che mi hanno preceduto in questa gestione e che per vari motivi non posso contattare per istruzioni.

    Provo a spiegarmi meglio. Le informazioni che voglio modificare solo per una categoria sono contenute non dentro il file “category.php” ma dentro “content.php”.

    Se cambio tali istruzioni e cioè, cambio la scritta “Scritto da” in “a cura di” la modifica funziona ma viene applicata a tutto il sito. Se effettuo la modifica in un file chiamato “content-nomecatoria.php” non succede niente.

    Se creo un file “category-nomecategoria.php” non trovo nessuna istruzione modificabile che a me serve direttamente. C’è sicuramente qualche stringa che richiama le istruzioni che io vorrei modificare ma per me risulta un po’ troppo complicato. So che magari sto chiedendo una cosa troppo specifica ma credo che tentar non nuoce. Se può esser utile potrei incollare i codici di “categpry.php” e “content.php”. Spero di essermi spiegato nel dettaglio. Grazie e buona serata.

    Chi ha creato la discussione Stefano82

    (@stefano82)

    Nessuno mi riesce ad aiutare?

    Chi ha creato la discussione Stefano82

    (@stefano82)

    Cerco di spiegarmi meglio. Incollo qui il codice del file che dovrei modificare considerato che la parte in questione non si trova nel file “category.php”. Non posso, quindi, risolvere il problema copiando il file “category.php” in “category.nomecategoria.php”.

    La scritta “Scritto da” si trova qui in questo file

    <?php
    
    /**
     * Content Template is used for every post format and used on single posts
     */
    
    // post has review? 
    $review = Bunyad::posts()->meta('reviews');
    
    ?>
    
    <article <?php
    	// hreview has to be first class because of rich snippet classes limit 
    	Bunyad::markup()->attribs('post-wrapper', array(
    		'id'        => 'post-' . get_the_ID(),
    		'class'     => ($review ? 'hreview ' : '') . join(' ', get_post_class()),
    		'itemscope' => '', 
    		'itemtype'  => 'http://schema.org/Article'
    	)); ?>>
    	
    
    		<?php 
    			/**
    			 * Set h1 tag on single post page
    			 */
    			$tag = 'h1';
    			if (!is_single() OR is_front_page()) {
    				$tag = 'h2';
    			}
    		?>
    
    		<<?php echo esc_attr($tag); ?> class="post-title" itemprop="name">
    		<?php if (is_single()): the_title(); else: ?>
    		
    			<a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
    				
    		<?php endif;?>
    		</<?php echo esc_attr($tag); ?>>
    		
    		<?php do_action('bunyad_comments_snippet'); ?>
    		
    	</header><!-- .post-header -->
    	
    	<div class="post-meta">
    		<span class="posted-by"><?php _ex('Scritto da', 'Post Meta', 'bunyad'); ?> 
    			<span class="reviewer" itemprop="author"><?php the_author_posts_link(); ?></span>
    		</span>
    		 
    		<span class="posted-on"><?php _ex('il', 'Post Meta', 'bunyad'); ?>
    			<span class="dtreviewed">
    				<time class="value-datetime" datetime="<?php echo esc_attr(get_the_time('c')); ?>" itemprop="datePublished"><?php echo esc_html(get_the_date()); ?></time>
    			</span>
    		</span>
    		
    		<span class="cats">
    			<?php 
    
    			// show categories
    			$categories = get_the_category();
    			if (!empty($categories)):
    				foreach ($categories as $category):
    				
    			?>
    			
    				<a href="<?php echo esc_url(get_category_link($category->term_id)); ?>" class="cat cat-color-<?php echo esc_attr($category->term_id); ?>"><?php 
    					echo esc_html($category->name); ?></a>
    			
    			<?php
    				endforeach;
    			endif;
    			
    			?>
    			
    		</span>
    	</div>
    	
    	<header class="post-header cf">
    		<?php if (!Bunyad::posts()->meta('featured_disable')): ?>
    		
    		<div class="featured">
    		
    			<?php if (get_post_format() == 'gallery'): // get gallery template ?>
    			
    				<?php get_template_part('partials/gallery-format'); ?>
    				
    			<?php elseif (Bunyad::posts()->meta('featured_video')): // featured video available? ?>
    			
    				<div class="featured-vid">
    					<?php echo apply_filters('bunyad_featured_video', Bunyad::posts()->meta('featured_video')); // sanitized html via lib/admin/meta-boxes.php ?>
    				</div>
    				
    			<?php else: ?>
    			
    				<?php 
    					/**
    					 * Normal featured image
    					 */
    			
    					$caption = get_post(get_post_thumbnail_id())->post_excerpt;
    					$url     = get_permalink();
    					
    					// on single page? link to image
    					if (is_single()):
    						$url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'); 
    						$url = $url[0];
    					endif;
    					
    					// which image?
    					$col_relative_width = Bunyad::get('motive')->block_relative_width();
    	
    					// more than 67% of .main-wrap?
    					$image = ($col_relative_width > 0.67 ? 'motive-slider-full' : 'motive-alt-slider');
    					
    					 
    				?>
    			
    			
    				<a href="<?php echo esc_url($url); ?>" itemprop="image" class="image-link"><?php the_post_thumbnail(
    						$image,  // larger image if no sidebar
    						array('title' => strip_tags(get_the_title()))
    					); ?>
    					
    					<?php 
    					if (!is_single()): 
    						do_action('bunyad_image_overlay');
    					endif; 
    					?>	
    				</a>
    								
    				<?php if (!empty($caption)): // have caption ? ?>
    						
    					<div class="caption"><?php echo esc_html($caption); ?></div>
    						
    				<?php endif;?>
    				
    			<?php endif; // normal featured image ?>
    		</div>
    		
    		<?php endif; // featured check ?>
    	
    	<div class="post-container cf">
    		<div <?php Bunyad::markup()->attribs('post-content', array(
    				'class' => 'post-content text-font description' . (Bunyad::posts()->meta('content_slider') ? ' post-slideshow' : ''),
    				'itemprop' => 'articleBody')); ?>>
    			
    			<?php
    			// excerpts or main content?
    			if (is_single() OR !Bunyad::options()->show_excerpts_classic OR Bunyad::posts()->meta('content_slider')): 
    				Bunyad::posts()->the_content();
    			else:
    				echo Bunyad::posts()->excerpt(null, Bunyad::options()->excerpt_length_classic, array('force_more' => true));
    			endif;
    			
    			?>
    			
    			<?php 
    			// multi-page post - add numbered pagination
    			if (!Bunyad::posts()->meta('content_slider')):
    				wp_link_pages(array(
    					'before' => '<div class="main-pagination post-pagination">', 
    					'after' => '</div>', 
    					'link_before' => '<span class="page-link">',
    					'link_after' => '</span>'));
    			endif;
    
    			// multi-page content slideshow post?
    			if (Bunyad::posts()->meta('content_slider')):
    				get_template_part('partials/content/pagination-next');
    			endif;
    			
    			?>
    			
    		</div><!-- .post-content -->		
    	</div>
    
    	<div class="post-footer cf">
    			
    		<?php if ((is_single() OR Bunyad::options()->show_tags_classic) && Bunyad::options()->show_tags): ?>
    		
    		<div class="post-tags"><?php the_tags('<i class="fa fa-tags"></i><span>' . __('Tags: ', 'bunyad') . '</span>', ''); ?></div>
    		
    		<?php endif; ?>
    
    		<?php get_template_part('partials/content/social-share'); ?>
    		
    	</div>
    		
    </article>
    
    <?php if (is_single() && Bunyad::options()->author_box) : // author box? ?>
    
    	<?php get_template_part('partials/author-box'); ?>
    
    <?php endif; ?>
    
    <?php if (is_single() && Bunyad::options()->post_navigation): ?>
    
    <section class="navigate-posts">
    
    	<div class="previous"><?php 
    		previous_post_link('<span class="main-color title"><i class="fa fa-angle-left"></i> ' . __('Notizia precedente', 'bunyad') .'</span><span class="link">%link</span>'); ?>
    	</div>
    	
    	<div class="next"><?php 
    		next_post_link('<span class="main-color title">'. __('Notizia successiva', 'bunyad') .' <i class="fa fa-angle-right"></i></span><span class="link">%link</span>'); ?>
    	</div>
    	
    </section>
    
    <?php endif; ?>
    
    <?php
    	// related posts template 
    	get_template_part('partials/content/related-posts'); 
    ?>
    

    C’è modo di intervenire solo su questo file? Magari con un comando “if”?
    Oppure devo mettere mano ad una serie di file del template?

    Grazie e scusate se sto postando così a lungo.

Stai visualizzando 8 risposte - dal 1 al 8 (di 8 totali)
  • Il topic ‘Cambiare “Scritto da” con “a cura di” oppure cancellare solo per una categoria’ è chiuso a nuove risposte.