Tagged: x
-
AuthorPosts
-
May 24, 2016 at 11:15 am #1007522
faquickParticipantHi,
I am trying to insert some content (an adsense ad) on the homepage (and also on the categories pages). I would like that the ad appears after only the first post in the list.
With other themes in the past I have been able to achieve that with a while loop, but I think I just cannot find the correct file to edit in X Theme (Ethos stack).
Also, I am using a child theme so please advise me in how to do so in the most future-proof way.
Thank you very much in advance.
May 24, 2016 at 11:58 am #1007599
ThaiModeratorHi There,
Because this requires a template change, I’d advise that you setup a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.
Then navigate to your child theme’s /framework/views/ethos directory create a file named _index.php and paste the code below:<?php // ============================================================================= // VIEWS/ETHOS/_INDEX.PHP // ----------------------------------------------------------------------------- // Includes the index output. // ============================================================================= $count = 0; $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $categories = get_categories( array( 'include' => x_get_option( 'x_ethos_filterable_index_categories' ) ) ); ?> <ul class="option-set unstyled" data-option-key="filter"> <li> <a href="#" class="x-index-filters cf"> <span class="x-index-filter-label"><?php _e( 'Filter by Topic', '__x__' ); ?></span> <i class="x-icon-chevron-down" data-x-icon=""></i> </a> <ul class="x-index-filters-menu unstyled"> <?php foreach ( $categories as $category ) { ?> <?php static $i = 1; $selected = ( $i == 1 ) ? 'class="selected"' : ''; ?> <li><a href="#" <?php echo $selected; ?> data-category-id="<?php echo $category->term_id ?>"><?php echo $category->name; ?></a></li> <?php $i++; ?> <?php } ?> </ul> </li> </ul> <div class="x-filterable-index"> <?php foreach ( $categories as $category ) { static $j = 1; $selected = ( $j == 1 ) ? ' selected' : ''; $accent = x_ethos_category_accent_color( $category->term_id, '#333333' ); $wp_query = new WP_Query( array( 'post_type' => 'post', 'paged' => $paged, 'cat' => $category->term_id ) ); echo '<div class="x-filterable-category-group' . $selected . '" data-category-id="' . $category->term_id . '">'; if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post(); $count++; x_get_view( 'ethos', 'content', get_post_format() ); if($count == 1){ ?> <img src="http://placehold.it/650x250" /> <?php } endwhile; endif; echo '<a href="' . get_category_link( $category->term_id ) . '" class="x-btn-filterable x-btn">See All ' . $category->name . ' Posts</a>'; echo '</div>'; wp_reset_query(); $j++; } ?> </div> <script> jQuery('.x-index-filters').click(function(e) { e.preventDefault(); var $this = jQuery(this); $this.parent().find('ul').slideToggle(600, 'easeOutExpo'); if ( $this.hasClass('selected') ) { $this.removeClass('selected'); } else { $this.addClass('selected'); } }); jQuery('.x-index-filters-menu a').click(function(e) { e.preventDefault(); var $this = jQuery(this); var $filter_cat = $this.data('category-id'); jQuery('.x-index-filter-label').text($this.text()); if ( ! $this.hasClass('selected') ) { $this.closest('ul').find('a').removeClass('selected'); $this.addClass('selected'); } jQuery('.x-filterable-category-group').each(function() { $this = jQuery(this); if ( $this.data('category-id') === $filter_cat ) { $this.css({ 'display' : 'block', 'visibility' : 'visible' }); $this.find('.x-btn-filterable').css({ 'display' : 'block' }); } else { $this.css({ 'display' : 'none', 'visibility' : 'hidden' }); } }); }); </script>Replace
<img src="http://placehold.it/650x250" />with your gooogle adsense code.Hope it helps 🙂
May 24, 2016 at 12:14 pm #1007619
faquickParticipantHi,
I already set up a child theme and I am using and customizing it.
I tried putting the _index.php you posted above inside the appropriate child theme folder, but it looks like nothing changes. I even tried putting incomplete or wrong text inside the php file but nothing changes.
but functions.php and language translations are correctly working inside the child theme folders.
What am I doing wrong?
May 24, 2016 at 12:44 pm #1007664
ThaiModeratorHi There,
Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:
– Link to your site
– WordPress Admin username / password
– FTP credentialsDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
Thanks.
May 24, 2016 at 12:44 pm #1007665
ThaiModeratorHi There,
Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:
– Link to your site
– WordPress Admin username / password
– FTP credentialsDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
Thanks.
May 24, 2016 at 7:24 pm #1008133
faquickParticipantThis reply has been marked as private.May 24, 2016 at 11:58 pm #1008500
LelyModeratorHello There,
Please double check above credentials or checkin with your hosting provider.
I can’t access your site. I am getting the following error:
Failed to load resource: net::ERR_EMPTY_RESPONSE
FTP credentials is not working too. I got this error:Timeout detected. (control connection) Connection failed.May 25, 2016 at 3:04 am #1008658
faquickParticipantYes, unfortunately we are experiencing an unrelated server outage that we are trying to solve together with our hosting provider.
I will let you know as soon as it is up and running again.
Thanks,
Fabrizio
May 25, 2016 at 4:20 am #1008733
LelyModeratorHi Fabrizio,
We’re sorry to hear that you’re having that issue.
We will wait then. Thank you for updating us.May 25, 2016 at 11:41 am #1009365
faquickParticipantHi,
you can try again now 🙂
thanks
May 25, 2016 at 6:07 pm #1009932
RadModeratorHi there,
Please remove the /framework/views/ethos/_index.php from your child theme, since your blog page has no filterable index, then you’ll be working on /framework/views/global/_index.php
And here is the code,
<?php // ============================================================================= // VIEWS/GLOBAL/_INDEX.PHP // ----------------------------------------------------------------------------- // Includes the index output. // ============================================================================= $stack = x_get_stack(); if ( is_home() ) : $style = x_get_option( 'x_blog_style' ); $cols = x_get_option( 'x_blog_masonry_columns' ); $condition = is_home() && $style == 'masonry'; elseif ( is_archive() ) : $style = x_get_option( 'x_archive_style' ); $cols = x_get_option( 'x_archive_masonry_columns' ); $condition = is_archive() && $style == 'masonry'; elseif ( is_search() ) : $condition = false; endif; ?> <?php if ( $condition ) : ?> <?php x_get_view( 'global', '_script', 'isotope-index' ); ?> <div id="x-iso-container" class="x-iso-container x-iso-container-posts cols-<?php echo $cols; ?>"> <?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); $count++ ?> <?php if ( $stack != 'ethos' ) : ?> <?php x_get_view( $stack, 'content', get_post_format() ); ?> <?php else : ?> <?php x_ethos_entry_cover( 'main-content' ); ?> <?php endif; ?> <?php if($count == 1) : ?> <img src="http://placehold.it/650x250" /> <?php endif; ?> <?php endwhile; ?> <?php else : ?> <?php x_get_view( 'global', '_content-none' ); ?> <?php endif; ?> </div> <?php else : ?> <?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); $count2++?> <?php x_get_view( $stack, 'content', get_post_format() ); ?> <?php if($count2 == 1) : ?> <img src="http://placehold.it/650x250" /> <?php endif; ?> <?php endwhile; ?> <?php else : ?> <?php x_get_view( 'global', '_content-none' ); ?> <?php endif; ?> <?php endif; ?> <?php pagenavi(); ?>And replace the two instance of
<img src="http://placehold.it/650x250" />with your own code.Cheers!
May 26, 2016 at 1:03 am #1010513
faquickParticipantGreat!
Thank you very much! 🙂
May 26, 2016 at 1:20 am #1010539
Rue NelModeratorYou’re welcome!
We’re glad we were able to help you out. -
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1007522 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
