Tagged: Hooks
-
AuthorPosts
-
November 4, 2017 at 3:08 pm #872532
Hi,
I want to insert some ads here: http://prntscr.com/h64i5x
I cant find a hook to insert a widget here though. Is there one?
- This topic was modified 7 years ago by Genetics Ed.
November 5, 2017 at 5:37 am #872689Hey geneticsed,
Did you use the Layout Builder for that page? If so then maybe it would be easier to put it in a Code Block element?
Best regards,
RikardNovember 5, 2017 at 8:31 am #872706is it allways ?
could you take the blog-widget for it – because you don’t use it elsewhere?
Then you can take that for itadd this to your functions.php of your child-theme:
add_action('ava_after_main_title', function() { if ( is_single() || is_singular( 'portfolio' ) ) { echo '<div class="container">'; echo do_shortcode("[av_sidebar widget_area='Sidebar Blog']"); echo '</div>'; } });
you see the if clause – you can do all the things an if-clause can do as is_page ; is_category; is_singular(‘event’) etc
if you don’t like to use blog widget for it
create an own widget just by adding one in widget area maybe call it after-titleadd_action('ava_after_main_title', function() { if ( is_single() || is_singular( 'portfolio' ) ) { echo '<div class="container">'; echo do_shortcode("[av_sidebar widget_area='after-title']"); echo '</div>'; } });
you only have to style it than via quick css
the width is still set via the container to your enfold width- This reply was modified 7 years ago by Guenni007.
November 5, 2017 at 10:28 am #872713Yes, I have created my own widget but I cant get it to display in the correct location. I used ‘ava_after_main_title’ but it appears here: http://prntscr.com/h6fesn and not where I originally specified.
I want it to appear on every page of my site in this location so using the Layout Builder is not a viable option.
November 5, 2017 at 10:43 am #872717i must see a live link.
and this is a bit different to the screenshot above. On the first one it is directly under the bread-crumps (title bar)
The woocommerce should go in that field ?
Determine if woocommerce got his own shortcode for that.Now you say it is for every page – than it will be better to create an own widget area with position determined.
This do_shortcode gives you the oportunity to place it directly above all content – the first position in main.to decide only from a screenshot nearly impossible.
click to enlarge – you see this was my test – just under breadcrump before the other main content.
- This reply was modified 7 years ago by Guenni007.
November 5, 2017 at 11:27 am #872722As you can see I’ve added the banner ad to some pages. The homepage using Layout Builder and the woocommerce pages using woocommerce hooks.
add_action( ‘woocommerce_before_shop_loop’, ‘adsense_hook’ );
add_action( ‘woocommerce_single_product_summary’, ‘adsense_hook’, 1 );But all other pages it is difficult when no hook exists
November 5, 2017 at 11:37 am #872725can you please insert the code to functions.php of your child-theme:
add_action('ava_after_main_title', function() { if ( is_page() || is_single() || is_singular( 'portfolio' ) ) { echo '<div class="container">'; echo do_shortcode("[av_sidebar widget_area='Sidebar Blog']"); echo '</div>'; } });
and than insert to sidebar blog everything you like to view on that area.
just to see where it is placedNovember 5, 2017 at 11:39 am #872726Done.
November 5, 2017 at 11:41 am #872727so you see it is the right position –
so now make an own widget ( without defining / registering ) just on widget area
name it you like f.e: under-titlemaybe without divs
add_action('ava_after_main_title', function() { if ( is_page() || is_single() || is_singular( 'portfolio' ) ) { echo do_shortcode("[av_sidebar widget_area='under-title']"); } });
put in there the things you likeNovember 5, 2017 at 11:46 am #872728No it’s not in the correct position. That widget spans full width. I want mine to only span the width of the main content area as outline here: http://prntscr.com/h6fesn and in the original post.
I do not want the widdet to span accross the left hand sidebar. Also the widget in the position you’re suggesting inserts the content into the title bar and not below it (as can be seen by the border-bottom).
- This reply was modified 7 years ago by Genetics Ed.
November 5, 2017 at 11:49 am #872730you want it besides the sidebar but over the first content ?
you can now remove it – i know what you like to have
- This reply was modified 7 years ago by Guenni007.
November 5, 2017 at 12:09 pm #872732exactly.
November 5, 2017 at 12:37 pm #872735function insert_container_overmain(){ ?> <script> jQuery(function() { jQuery('#main .av-content-small:first-child').prepend('<div id="overmain"> </div>'); jQuery('#overmain').css('height', ' 120px'); }); </script> <?php } add_action('wp_head', 'insert_container_overmain');
this will be the right position. –
but i do not know how to get in the prepended content the do_shortcode ruleand this is only for pages/posts with sidebar !
November 5, 2017 at 12:47 pm #872738Thanks Guenni007 I’ll try it out later. Much appreciated.
November 5, 2017 at 1:24 pm #872746function insert_container_overmain(){ ?> <script> jQuery(function() { jQuery("#main .content.av-content-small:first-child").prepend("<div class='overmain'> </div>"); jQuery(".avia-section .overmain").removeClass("overmain"); jQuery(".overmain").css("height", "120px"); }); </script> <?php } add_action('wp_head', 'insert_container_overmain');
not knowing how to get in there the widget.
November 6, 2017 at 7:21 am #872929this is another method – but because color-section is content too it will be before it:
function insert_before_content($content) { $beforecontent = '[av_sidebar widget_area="under-title"]'; $fullcontent = $beforecontent . $content ; return $fullcontent; } add_filter('the_content', 'insert_before_content');
- This reply was modified 7 years ago by Guenni007.
November 6, 2017 at 9:34 am #872943That last method outputs it beneath the content title and main image: https://futuregenetic.com/what-is-dna/
- This reply was modified 7 years ago by Genetics Ed.
November 6, 2017 at 10:44 am #872955November 6, 2017 at 10:54 am #872958ok – on my end it works except if there is color-section – than it is above.
now my skills are at their finish –guess you have to wait til mods are here. – Maybe there is an easy method.
i read a lot of ajax and the possibility to get in dynamic content – but this goes over my needs to help you now furthermore.November 6, 2017 at 11:27 am #872966one off topic question – how did you insert in footer (not socket) the social bookmarks
November 6, 2017 at 8:10 pm #873325Off topic: Custom HTML widget with this code:
<ul class="noLightbox social_bookmarks icon_count_3"> <li class="social_bookmarks_facebook av-social-link-facebook social_icon_1"> <a target="_blank" href="#" aria-hidden="true" data-av_icon="" data-av_iconfont="entypo-fontello" title="Facebook"> <span class="avia_hidden_link_text"> Facebook</span> </a> </li> <li class="social_bookmarks_twitter av-social-link-twitter social_icon_2"> <a target="_blank" href="#" aria-hidden="true" data-av_icon="" data-av_iconfont="entypo-fontello" title="Twitter"> <span class="avia_hidden_link_text"> Twitter</span> </a> </li> <li class="social_bookmarks_youtube av-social-link-youtube social_icon_6"> <a href="#" aria-hidden="true" data-av_icon="" data-av_iconfont="entypo-fontello" title="Youtube"> <span class="avia_hidden_link_text"> Youtube</span> </a> </li> </ul>
November 6, 2017 at 8:14 pm #873328aha – i wrote a custom widget for it : https://kriesi.at/support/topic/social-bookmarks-widget-how-to/
November 6, 2017 at 8:26 pm #873331Nice. Thanks for that.
November 6, 2017 at 9:58 pm #873359Any help from kriesi mods would be greatly appreciated. Thanks
November 7, 2017 at 4:55 am #873525Hi,
Use the “ava_after_main_title” hook then move the adsense code inside a container with a unique id or class attribute. Create a custom script to prepend the container inside the “entry-content-wrapper” container. Example.
$('.adsense-container</code>‘).prependTo(‘.entry-content-wrapper’);
Best regards,
IsmaelNovember 7, 2017 at 8:03 pm #873877Seriously, that’s the easiest way?
I’m astonished there’s no hook at the location I want.
November 8, 2017 at 6:09 am #874024Hi,
Yes, unfortunately, there’s no available hook inside that container. You can also insert the adsense code directly inside the single.php file, just above the following code.
get_template_part( 'includes/loop', 'index' );
Best regards,
IsmaelNovember 8, 2017 at 9:05 pm #874313That seems like a better solution. But is it possible to insert a custom hook at that location using my child theme?
November 9, 2017 at 7:22 am #874494Hi,
Yes, it’s possible. However, you’re just making things a bit more complicated. You can just insert the code directly in the template.
Best regards,
IsmaelNovember 9, 2017 at 11:25 am #874596ok, I copied single.php to my child theme and added the code. Thanks for the help.
-
AuthorPosts
- You must be logged in to reply to this topic.