Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
Shortcode no funciona en la llamada ajax en Wordpress

Tengo un gran problema al cargar contenido ajax en Wordpress. La carga de Ajax funciona, pero dentro del archivo cargado hay un código abreviado que se muestra como texto sin formato. Probé muchas soluciones que se suponía que iban a funcionar, pero ninguna funciona... Mi código es:

echo do_shortcode( apply_filters( 'the_content', $post->post_content ) );

Pero incluso si codifico el código abreviado, todavía se muestra como texto sin formato. En realidad, uso el complemento Contenido sin caché , pero probé cosas diferentes y el resultado es el mismo. Necesito ejecutar este shortcode. Necesito usar ajax para evitar el caché. ¿Algunas ideas?

Este es mi código completo por ahora:

 add_action( 'wp_ajax_showBanner', 'showBanner' ); add_action( 'wp_ajax_nopriv_showBanner', 'showBanner' ); function showBanner() { echo do_shortcode( '[adrotate group="1"]' ); wp_die(); } function getBanner() { echo '<div class="adr"></div> <script> window.addEventListener( "load", function() { var xhttp = new XMLHttpRequest(); xhttp.open("POST", "' . admin_url( 'admin-ajax.php' ) . '", true); xhttp.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded;"); xhttp.onload = function () { if (this.status >= 200 && this.status < 400) { document.querySelector( ".adr" ).innerHTML = this.responseText; } else { document.querySelector( ".adr" ).innerHTML = "Error"; } }; xhttp.send("action=showBanner"); }); </script>';

}

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!