Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
2.9k views
in Q2A Core by
Is there a way to put adsense in the middle of answer text? For example after 200 characters of the answer text.

2 Answers

0 votes
by
edited by

Make A Advance Theme and Put This code In Your  qa-theme.php

<?php
 
/*
You can place ads at below 4 spots
1. ad after menu navigation bar, just after horizontal line.
2. ad after question, just before answers.
3. ad after all answers, just before related questions.
4. ad after related questions.
*/
 
    class qa_html_theme extends qa_html_theme_base
    {
 
        function header()
        {
            qa_html_theme_base::header();
 
            //ad after menu navigation bar, just after horizontal line.
            //Put your ad code in between below brackets
            ?>
Your Ad Code
            <?
        }
 
        function q_view()
        {
            qa_html_theme_base::q_view();
 
            //ad after question, just before answers
            //Put your ad code in between below brackets
            ?>
Your Ad Code
            <?
 
        }
 
        function a_list()
        {
            qa_html_theme_base::a_list();
 
            //ad after all answers, just before related questions
            //Put your ad code in between below brackets
            ?>
Your Ad Code
            <?
 
        }
 
        function question_main()
        {
            qa_html_theme_base::question_main();
 
            //ad after related questions
            //Put your ad code in between below brackets
            ?>
Your Ad Code
            <?
        }
    }
?>
 
by
Just to add adsense to site requires messing with PHP code. Somebody needs to rethink the design of Q2A.

How can you attract non-geeky types with this type of stuff?
by
@finid, actually no you don't need to do the above just to add Adsense. There are several built in positions you can add content in the Admin area. I also made a plugin to add it to specific pages/positions: https://github.com/svivian/q2a-widget-anywhere

And Tomi's question is actually about putting the ad right in the middle of an answer, which is a complex and unusual request, never gonna be simple for a non-geek.
+2 votes
by
Putting an ad in the middle of an answer is a very complex request. You need to figure out not just 200 characters, but the end of a sentence or paragraph. If you are using the HTML editor this is basically impossible because you risk breaking up some HTML and causing big problems.

You can follow Robin's answer to put an ad in a few positions, or try my plugin that makes things a little easier: https://github.com/svivian/q2a-widget-anywhere

Another possibility would be to manually add the code to each answer. You can use Noah's shortcode plugin: https://github.com/NoahY/q2a-shortcode
Add a code to display your advert, e.g. {adsense} then add that to the right place in each answer. It's a pain but probably the only way to do exactly what you want without breaking stuff.
by
Thanks Scott. You have helped me with Shortcut plugin. Tnx again
by
Please provide an example, you will be highly appreciated.
by
Why don't use Google autoads? Ads will be placed automatically by Google
by
Auto Ads are not appropriately placed, thanks for your suggestion.
by
Please explain how to create an adsense shortcode.
...