Support only during business hours : Monday to friday, from 8:30 am – 5:30 pm CEST

In regards to the COVID-19 situation

Your support team is currently doing their best to offer the best support possible despite the current COVID-19 situation. However during these exceptional circumstances, please note that you should expect a response time of 2-3 business days, until further notice.Rest assured that we will still do our best to handle your requests as soon as possible! Everyone stay safe and healthy! 😷

Buddypress ads inside activity

This topic is resolved
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • Muamer
    Participant
    • 13 Topics
    • 33 Posts

    Hi, again.
    I have one question more.
    I am using this code:

    function buddydev_inject_content_after_n_activities0() {
        static $current_activity_index = 1;
     
        // change $n to the correct number of activities.
        $n = 7; // After how many activities you want to inject content.
     
        if ( $current_activity_index % $n === 0 ) {
            ?>
            <li id="advertbuddy" class='activity-item activity-ad-item activity-custom-entry'>
                <?php echo adrotate_ad(7); ?>
            </li>
            <?php
            // show the activity injected content.
        }
        // increment the current index.
        $current_activity_index ++;
     
    }
     
    add_action( 'bp_after_activity_entry', 'buddydev_inject_content_after_n_activities' );

    That will inject ad code after 7th activity, and it will be 8th activity.
    The problem is when other tab is clicked, adsense says avaiable width is zero,0.

    Manathan
    Keymaster
    Themosaurus Support
    • 0 Topics
    • 2012 Posts

    Hi @mllapan,

    Please note that this issue is related with the customization of a third party plugin, not with the use of your theme. As theme authors, the installation, setting or debugging of third party plugins isn’t part of the support we will provide.

    We only share snippet only to solve issues with our theme. Any further request for CSS snippets will have to be part of a defect that needs to be fixed urgently. No snippets will be shared otherwise.

    If you want to go further with the customization of your website, we advise that you hire a freelancer to do it for you.

    If you’re on a tight budget, we recommend you to require the services from Envato Studio freelancers (https://studio.envato.com/explore/websites-programming). This web platform gives you access to developers who have already experience with theme customizations, and for very competitive prices.

    Thank you for your understanding.

    Muamer
    Participant
    • 13 Topics
    • 33 Posts

    It is about the theme, because it was styled by FLEX.
    I asked the same question for bbpress, but until today, I did not realized it was the same problem, now I am.

    Yeah, the theme is built by flex css, and you need to provide fix for responsive ads inside your theme for your customers, or apply the fix to theme update on the primary div, as the most of the people use adsense code.

    I am not the only one, many people asked the same, but they did not realized they have problem with the way of theme styling, and they are trying to change php functions instead:
    https://support.themosaurus.com/forums/search/adsense/

    Muamer
    Participant
    • 13 Topics
    • 33 Posts

    This is not about BuddyPress, BBpress, it is also the problem of the single posts, single pages too.
    Any adsense on single posts, single pages will push sidebar in the new row, because responsive adsense ad is able to push flex box to full width of the screen.
    The problem is called flex in the theme.

    Manathan
    Keymaster
    Themosaurus Support
    • 0 Topics
    • 2012 Posts

    Hi @mllapan,

    Could you provide us with screenshots of your website please? Please don’t hesitate to comment or highlight your screenshots to help us better understand your issue.

    Could you share the URL of the exact page so I can investigate on this issue, please? You can post it in your next reply and mark it as private to keep this between us.

    Thank you.

    Muamer
    Participant
    • 13 Topics
    • 33 Posts

    Hi, @themodactyl.

    Here is the screenshot.
    It does not matter what kind of code is used, even if you use lets say Ads Inserter plugin, once Adsense is inserted into between paragraphs, or into bbpress topic page, or anything inside normal page text, it will stretch primary div into full width of the screen and will push down sidebar under primary div.

    I am saying this all the time, but seems no one understands me.
    It is not about the code I, or anyone else use to inject ads, but about flex styling.

    For example, if I use width: 600px !important, than, the advertisement will not push sidebar to a new row, under the primary div. but than that is not any responsive advertisement and looks bad on mobile, or if you make it good on mobile, it will look too small on desktop.
    We need some javascript or jQuery that will prohibit adsense ads do this with flex css.

    You can acomplish the same with child theme and using this:
    – Put your single post template to have sidebar, add any widget in sidebar.
    Use this in functions:

    add_filter( 'the_content', 'post_ads_1_paragraph' );
     
    function post_ads_1_paragraph( $content ) {
        $ad_code = '<div class="advertparagraph">
    
    <blockquote>PUT ADSENSE CODE IN HERE OR ADROTATE SHORTCODE.</blockquote>
    
    </div>';
     
        if ( is_single() && ! is_admin() ) {
            return prefix_insert_after_1nd_paragraph( $ad_code, 1, $content );
        }
         
        return $content;
    }
      
    function prefix_insert_after_1nd_paragraph( $insertion, $paragraph_id, $content ) {
        $closing_p = '</p>';
        $paragraphs = explode( $closing_p, $content );
        foreach ($paragraphs as $index => $paragraph) {
     
            if ( trim( $paragraph ) ) {
                $paragraphs[$index] .= $closing_p;
            }
     
            if ( $paragraph_id == $index + 1 ) {
                $paragraphs[$index] .= $insertion;
            }
        }
         
        return implode( '', $paragraphs );
    }

    The code will inject ad after first paragraph.
    Than clear the cache, and you will see ad is pushing sidebar under the primary div.

    Manathan
    Keymaster
    Themosaurus Support
    • 0 Topics
    • 2012 Posts

    Hi @mllapan,

    Thank you for your feedback.

    It’s best if we take a quick look at this…

    Could you create a new website user for us please? If possible with administrator capabilities so we can make a quick check of your settings.
    You can post the user name and password in your next reply and mark it as private to keep this between us.

    Could you share the URL of the exact page so we can investigate on this issue, please? You can post it in your next reply and mark it as private to keep this between us.

    Also, are we free to deactivate plugins for our tests? In this case, I invite you to make a backup before we investigate your website further in order to make sure you don’t loose any data if something goes wrong.

    Thank you.

Roboraptor 🦖
Themosaurus Topic Closer

Hi there,

This topic has been inactive for a while now so we will be closing it to keep the forum tidy. Don't hesitate to create a new topic if you still need help and we'll be glad to help you!

Best regards,
The Themosaurus team.

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Buddypress ads inside activity’ is closed to new replies.

Troubleshooting Demo Imports

You're trying to setup your theme but you're experiencing errors when importing the demo content? Or you've just followed the setup guide but your website doesn't look exactly like our demo? These are common issues for which you can find easy and quick fixes.

Happy With our Support So Far?

Feel free to review our theme on Themeforest! It helps us making our products more known to new potential customers, which allow us more time to improve the quality and develop new features. #SharingIsCaring ❤️