¿Cómo mostrar Adsense en la primera entrada del home en WordPress?

Ro101 Seguir

Lambda
Verificación en dos pasos desactivada
Desde
30 Nov 2010
Mensajes
2.806
Hola a todos! tengo una gran duda...

Yo tengo implementado Adsense con Adman dentro de cada uno de mis posts, pero al ver el home de mi Blog de WP estos no aparecen. Obviamente que solo podria visualizar 3 en total y si estoy mostrando 5 entradas seria imposible que se vea en todas las del home.

Me gustaria que al menos en la primer entrada de las 5 que aparecen en mi pagina principal se muestre el bloque que figura bajo el titulo en cada uno de mis posts al ser accedidos.

Hay algun plugin para ello? Tengo que modificar algo en el codigo (si es asi, que cosa?)?

Gracias! :vollkommenauf:
 

Plaga

Moderador
1
Sigma
Verificado
Verificación en dos pasos activada
Verificado por Whatsapp
¡Ha verificado su Paypal!
Verificado por Binance
¡Excelente comerciante!
Suscripción a IA
Desde
15 Abr 2009
Mensajes
10.899
Lo puedes hacer con código, con plugin no se.

Si quieres que aparezca solo en la primera entrada edita el archivo index.php de tu theme y coloca esto en donde quieres que se vea AdSense.

PHP:
<center>
<?php if ( $count == 0 ) : ?>
TU CODIGO DE ADSENSE AQUI
<?php endif // ( $count == 0 ) ?>
<?php $count++ ?>
</center>

Y si quieres que se muestre en las 5 entradas puedes usar este:
Yo uso bloques en las primeras 3 y en las 2 restantes tengo enlaces, puedes verlo en mi blog Enlace eliminado

PHP:
<!--Inicia AdSense -->
<center>
<?php if ( $count == 0 ) : ?>
CODIGO ADSENSE 1
<?php endif // ( $count == 0 ) ?>
<?php if ( $count == 1 ) : ?>
CODIGO ADSENSE 2
<?php endif // ( $count == 1 ) ?>
<?php if ( $count == 2 ) : ?>
CODIGO ADSENSE 3
<?php endif // ( $count == 2 ) ?>
<?php if ( $count == 3 ) : ?>
CODIGO ADSENSE 4
<?php endif // ( $count == 3 ) ?>
<?php if ( $count == 4 ) : ?>
CODIGO ADSENSE 5
<?php endif // ( $count == 4 ) ?>
<?php $count++ ?>
</center>
<!--Termina AdSense -->

Espero te sirva!
 

espartan1047

Iota
Redactor
Verificación en dos pasos desactivada
Desde
25 Ene 2010
Mensajes
2.336
mmm haber creo que entiendo...

quieres que se muestre un banner de adsense debajo del primer post, sin importar si se esta en la pagina 1 o 2,

algo asi como mi blog
Enlace eliminado ?

pues es facil, solo añade este codigo a tu theme en el archivo index.php

Insertar CODE, HTML o PHP:
<?php if ($count == 0) : ?>
codigo de adsense
<?php endif; $count++; ?>

Coloca el codigo que te mostre justo despues de las lineas:
?php the_content('Read More »'); ?>

o despues de este dependiendo el theme, experimenta:

<?php endwhile; else : ?>
 

Ro101

Lambda
Verificación en dos pasos desactivada
Desde
30 Nov 2010
Mensajes
2.806
Gracias por la respuesta! Alli hablan de Blogger, pero veo que uno de los usuarios dejo el siguiente codigo:

Insertar CODE, HTML o PHP:
<?php $num=0; if (have_posts()) : ?><?php  while (have_posts()) : the_post(); $num++; ?>
<!-- Adsense entre post -->
<?php if ($num==2)
     {echo '<center><strong>Adsense en el segundo post</strong></center>';}
     if ($num==3)
     {echo '<center><strong>Adsense en el tercer post</strong></center>';} 
?>
<!-- Adsense entre post -->

Lo probare y les comento! :D

Tengo una duda con respecto a las respuestas. Esto es lo que tengo en mi index.php:

Insertar CODE, HTML o PHP:
<?php
/**
 * The main template file.
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query. 
 * E.g., it puts together the home page when no home.php file exists.
 * Learn more: http://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage Graphene
 * @since Graphene 1.0
 */

get_header(); ?>
	<?php
    /* Run the loop to output the posts.
     * If you want to overload this in a child theme then include a file
     * called loop-index.php and that will be used instead.
     */
     get_template_part('loop', 'index');
    ?>
            
<?php get_sidebar(); ?>
<?php get_footer(); ?>

Donde deberia colocar el codigo que me pasaron?

Si es en el loop.sh en que parte iria?

Esto es mi loop.sh

Insertar CODE, HTML o PHP:
<?php if (have_posts()) : ?>
	<?php while (have_posts()) : the_post(); ?>
            <div id="post-<?php the_ID(); ?>" <?php post_class('clearfix post'); ?>>
            
            	<?php /* Posts navigation for single post pages, but not for Page post */ ?>
                <?php if (is_single() && !is_page()) : ?>
            	<div class="post-nav clearfix">
                    <p id="previous"><?php previous_post_link(); ?></p>
                    <p id="next-post"><?php next_post_link(); ?></p>
                    <?php do_action('graphene_post_nav'); ?>
                </div>
                <?php endif; ?>
                
                <?php /* Post date is not shown if this is a Page post */ ?>
                <?php if (!is_page() && (get_option('graphene_hide_post_date') != true)) : ?>
                <div class="date">
                    <p class="default_date"><?php the_time('M'); ?><br /><span><?php the_time('d') ?></span></p>
                    <?php do_action('graphene_post_date'); ?>
                </div>
                <?php endif; ?>
                
                <div class="entry clearfix<?php if (get_option('graphene_hide_post_date') == true) {echo ' nodate';} ?>">
                
                	<?php /* Post title */ ?>
                    <h2 class="post-title">
                    	<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(esc_attr__('Permalink Link to %s', 'graphene'), the_title_attribute('echo=0')); ?>"><?php if (get_the_title() == '') {_e('(No title)','graphene');} else {the_title();} ?></a>
                    <?php do_action('graphene_post_title'); ?>
                    </h2>
                    
					<?php /* Post meta */ ?>
                    <div class="post-meta clearfix">
                    	
						<?php /* Post category, not shown if this is a Page post or if admin decides to hide it */ ?>
                        <?php if (!is_page() && (get_option('graphene_hide_post_cat') != true)) : ?>
                        <ul class="meta_categories">
                            <li><?php the_category(",</li>\n<li>") ?></li>
                        </ul>
                        <?php endif; ?>
                        
                        <?php /* Post author, not not shown if this is a Page post or if admin decides to hide it */ ?>
                        <?php if (get_option('graphene_hide_post_author') != true) : ?>
                        <p class="post-author">
							<?php
								if (!is_page()) {
									/* translators: this is for the author byline, such as 'by John Doe' */
									_e('by','graphene'); echo ' '; the_author_posts_link();
								}
								edit_post_link(__('Edit post','graphene'), ' (', ')');
								
								/* Show the post author's gravatar if enabled */
								if (get_option('graphene_show_post_avatar') && !is_page()) {
									echo get_avatar(get_the_author_meta('user_email'), 40);
								}
							?>
                        </p>
                        <?php endif; ?>
                        
                        <?php do_action('graphene_post_meta'); ?>
                    </div>
                    
                    <?php /* Post content */ ?>
                    <div class="entry-content clearfix">
                    	<?php do_action('graphene_before_post_content'); ?>
                        
                    	<?php if (!is_search() && !is_archive() && (!get_option('graphene_posts_show_excerpt') || is_single() || is_page())) : ?>
                        <?php the_content(__('Read the rest of this entry &raquo;','graphene')); ?>
                        <?php else : ?>
                        	<?php the_excerpt(); ?>
                        <?php endif; ?>
                        <?php wp_link_pages(array('before' => __('<p><strong>Pages:</strong> ','graphene'), 'after' => '</p>', 'next_or_number' => 'number')); ?>
                        
                        <?php do_action('graphene_after_post_content'); ?>
                        
                    </div>
                    
                    <?php /* Post footer */ ?>
                    <div class="entry-footer clearfix">
                    	<?php /* Display the post's tags, if there is any */ ?>
                        <?php if (!is_page() && (get_option('graphene_hide_post_tags') != true)) : ?>
                        <p class="post-tags"><?php if (has_tag()) {_e('Tags:','graphene'); the_tags(' ', ', ', '');} else {_e('This post has no tag','graphene');} ?></p>
                        <?php endif; ?>
                        
						<?php 
							/**
							 * Display AddThis social sharing button if single post page, comments popup link otherwise.
							 * See the graphene_addthis() function in functions.php
							*/ 
						?>
                        <?php if (is_single() || is_page()) : ?>
                            <?php graphene_addthis(get_the_ID()); ?>
                        <?php elseif (get_option('graphene_hide_post_commentcount') != true && comments_open()) : ?>
                        	<p class="comment-link"><?php comments_popup_link(__('Leave comment','graphene'), __('1 comment','graphene'), __("% comments",'graphene')); ?></p>
                        <?php endif; ?>
                        
                        <?php do_action('graphene_post_footer'); ?>
                    </div>
                </div>
            </div>
            <?php 
			/**
			 * Display the post author's bio in single-post page if enabled
			*/
			if (is_single() && get_option('graphene_show_post_author')) :
			?>
            <h4 class="author_h4"><?php _e('About the author', 'graphene'); ?></h4>
            <div class="author clearfix">
            	<?php echo get_avatar(get_the_author_meta('user_email'), 100); ?>
                <p class="author_name"><strong><?php the_author_meta('display_name'); ?></strong></p>
                <p class="author_bio"><?php the_author_meta('description'); ?></p>
                
            </div>
            <?php endif; ?>
            
            <?php 
			/**
			 * Display Adsense advertising for single post pages 
			 * See graphene_adsense() function in functions.php
			*/ 
			?>
            <?php if (is_single() || is_page() || (is_front_page() && get_option('graphene_adsense_show_frontpage')) || is_archive() || is_search()) {graphene_adsense();} ?>
            
            <?php /* Get the comments template for single post pages */ ?>
            <?php if (is_single() || is_page()) {comments_template();} ?>
            
	<?php endwhile; ?>
    
    <?php /* Display posts navigation if this is not a single post page */ ?>
    <?php if (!is_single()) : ?>
        <?php /* Posts navigation. See functions.php for the function definition */ ?>
    	<?php graphene_posts_nav(); ?>
    <?php endif; ?>
    
<?php /* If there is no post, display message and search form */ ?>
<?php else : ?>
    <div class="post">
        <h2><?php _e('Not found','graphene'); ?></h2>
        <div class="entry-content">
            <p>
			<?php 
				if (!is_search())
					_e("Sorry, but you are looking for something that isn't here. Wanna try a search?","graphene"); 
				else
					_e("Sorry, but no results were found for that keyword. Wanna try an alternative keyword search?","graphene"); 
			?>
                
            </p>
            <?php get_search_form(); ?>
        </div>
    </div>
    
    <?php do_action('graphene_not_found'); ?>
<?php endif; ?>

<?php do_action('graphene_bottom_content'); ?>

Gracias a todos!
 
Última edición:

Felipe

Iota
Redactor
Verificación en dos pasos activada
Desde
21 Jun 2009
Mensajes
2.414
seguramente tienes otro archivo que se llama: "loop-index.php"... alli se encuentra el codigo del index y es ese el que tienes que editar.
 

Ro101

Lambda
Verificación en dos pasos desactivada
Desde
30 Nov 2010
Mensajes
2.806
Gracias a todos! Finalmente pude hacerlo incluyendo la entrada en el loop.sh justo antes de
Insertar CODE, HTML o PHP:
?php the_content('Read More »'); ?>
como me habian indicado antes para el index.php! Esperemos esto traiga mas clicks! :D
 

Nicoolas

Gamma
Redactor
Verificación en dos pasos desactivada
Desde
3 Dic 2009
Mensajes
455
Gracias por la respuesta! Alli hablan de Blogger, pero veo que uno de los usuarios dejo el siguiente codigo:

Código:
<?php $num=0; if (have_posts()) : ?><?php while (have_posts()) : the_post(); $num++; ?>
<!-- Adsense entre post -->
<?php if ($num==2)
{echo '<center><strong>Adsense en el segundo post</strong></center>';}
if ($num==3)
{echo '<center><strong>Adsense en el tercer post</strong></center>';}
?>
<!-- Adsense entre post -->
Lo probare y les comento!

Si, ya se que hablaban de blogger, pero dejaron la respuesta para Wordpress como viste, espero que te haya servido...
 

¡Regístrate y comienza a ganar!

Beneficios

  • Gana dinero por participar
  • Gana dinero por recomendarnos
  • Descubre ofertas de empleo diariamente
  • Negocios seguros
  • ¡Información premium y más!

Acceder

¿Ya tienes una cuenta? Accede aquí

Arriba