Q&A and Ajax the_content pulling complete header where there is none

please have a look at my site

https://www.entrepreneurship.de/call-to-action/kursprogramm/oktober/

click the link within the purple box and load a question under the “Fragen & Diskussion” section

everything non Q&A related works fine

but the_content in both the questions and answers load a complete header and its messing up my html structure.

when i use $post -> post_content its fine

(but i do not want to alter core files) and i dont think its where the problem originates from anyways just some really weird ajax shit.

please help!!

i am on a tight shedule

its driving me crazy – i am clueless by now

  • Hannes
    • Design Lord, Child of Thor

    so, ye

    after quite a while i figured out that the_content() gets filtered

    and the plugin adds complete templates before the content

    $prepend_content = $this->get_template_details( QA_PLUGIN_DIR . ‘/default-templates/archive-question-single.php’, array(), false, false );

    $content = $content . $prepend_content;

    NOT A FAN OF THIS

    im not sure why you would load a complete template with “the_content()” that is already inside a q&a template

    i now use

    “<div id=”question-content”><?php echo $post -> post_content;?></div>”

    in my question template

    i load my answers in the sametemplate as my questions

    even though the correct data is fetched and its clearly a type “answer”

    global($post) still holds posttype = question

    thus applying the filter to my answers as well

    unfortunately for this i had to alter core files since these display with

    <?php the_answer_list(); ?>

    wich is located in qa /core/template-tags.php

    ….

    //$out .= apply_filters( ‘the_content’, $answer->post_content );

    $out .= $answer->post_content ;

    …..

    took my way too long to figure this out.

    fortunately the issue of multiple alerts is solved now as well – makes sense (no ghost template anymore)

    now i will just have to get rid of any “/wp-admin/admin-ajax.php”

    in my forms > prolly quick n dirty with jquery

    and have a look at the report and edit functions

    to ajaxify them as well

    also find a way to stop user redirects

    and then i think im happy

    really would have loved a dev level documentation for this

  • Nithin Ramdas
    • Support Wizard

    Hi Hannes,

    Hope you are doing good today. :slight_smile:

    It seems like you have figured out your initial question? And if I'm not mistaken, now you are trying to perform these?

    now i will just have to get rid of any "/wp-admin/admin-ajax.php"

    in my forms > prolly quick n dirty with jquery

    and have a look at the report and edit functions

    to ajaxify them as well

    also find a way to stop user redirects

    Did you edit your core plugin files? Since you have edited the plugin core files, I'm afraid it's pretty tough to suggest without checking how your website functions, could you please enable support access, so that we could check how your website functions, and see whether any quick workaround is possible?

    minor bug

    or is this supposed to be set with javascript? (default non ajax version)

    Did you mean the green tick mark? I tested this in a default WordPress theme, and it does look, and works fine in a default theme without any issue.

    [attachments are only viewable by logged-in members]

    So this is a theme specific issue. I'm not able to check your questions page, as it's showing a blank page. Please advise if I'm missing out anything.

    [attachments are only viewable by logged-in members]

    You could try the following CSS code, and check whether it works:

    input[type=submit].vote-accepted-on, .vote-accepted-on {
    margin-top: 10px;
    }

    You can add the above CSS code, using Custom CSS box(if your theme offers), or either using a Child theme, or a plugin like Simple Custom CSS.

    If the above code doesn't work, then a link to the page would be helpful. Please advise if I had missed out anything, have a nice day. :slight_smile:

    Kind Regards,

    Nithin

  • Hannes
    • Design Lord, Child of Thor

    hey,

    yes i figured out it had something to do with the missing init.js file

    since i load content with ajax i had to manually add it.

    i updated the wpmudev dashboard and granted support access.

    also noted the issues open to solve there

  • Kasia Swiderska
    • Support nomad

    Hello Hannes,

    Thanks, I found that site. I have to consult coding issues with our developer – I send him message, but at the moment he is not online, so I'm waiting for his respons.

    About your second question

    my membership plugin redirects if a user tries to open a site he has no access to

    this does not work on /question/ pages

    i assume it is becasue the Q&A plugin creates virtual pages.how could i solve this?

    Yes, Q&A has virtual pages, but your plugin handles URI protection for plugins that are using virtual pages (like also BuddyPress). You can use part of the url and protect it in "URI restrictions"

    [attachments are only viewable by logged-in members]

    – part with "questions" should work for all the Q&A pages.

    kind regards,

    Kasia

  • Hannes
    • Design Lord, Child of Thor

    hey Kasia,

    ok, nice to hear you have support access now.

    for the page restrictions: but of course – thank you.

    i will clean up my threads next week – they gotten a little out of hand.

    many issues have been solved by now.

    thank you