Title: Create shortcode for APA citation format
Last modified: December 19, 2023

---

# Create shortcode for APA citation format

 *  Resolved [ppantaleo](https://wordpress.org/support/users/ppantaleo/)
 * (@ppantaleo)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/create-shortcode-for-apa-citation-format/)
 * Hi, I have created a code to be able to cite with APA format. Without the plugin
   it can be created fine, but when I install the plugin I can’t get Last name, 
   I. The function get_multiple_authors(); takes me the full name of the authors,
   if I add initials, it repeats them. The actual citation I get is:
   Geraldine Trujillo(
   December 19, 2023). Predatory and unreliable journals, publishers and metrics.
   Paideia Studio [Blog]. [https://paideiastudio.net/revistas-editoriales-metricas-predatorias/](https://paideiastudio.net/revistas-editoriales-metricas-predatorias/).
 * When it should be:
 * Trujillo, G. (19 December, 2023). Predatory and unreliable magazines, publishers
   and metrics. Paideia Studio [Blog]. [https://paideiastudio.net/revistas-editoriales-metricas-predatorias/](https://paideiastudio.net/revistas-editoriales-metricas-predatorias/).
 * The same thing happens in Multiplautores. I don’t have a published example yet.
 * The code is:
 *     ```wp-block-code
       // Nuevo shortcode personalizado [mi_shortcode_cita]
       add_shortcode('mi_shortcode_cita', 'mi_shortcode_cita_func');
   
       function mi_shortcode_cita_func() {
           // Obtener datos necesarios para la cita desde la publicación actual
           $authors = get_multiple_authors();
   
           $author_parts = array();
   
           foreach ($authors as $author) {
               // Obtener el nombre completo del autor
               $author_name = $author->display_name;
   
               $author_parts[] = $author_name;
           }
   
           $authors_str = implode(' & ', $author_parts);
   
           $publication_date = get_the_date();
           $title = get_the_title();
           $sitename = get_bloginfo('name');
           $permalink = get_permalink();
   
           // Construir la etiqueta de cita según el formato deseado
           $cita = sprintf(
               '%s. (%s). %s. %s [Blog]. %s.',
               $authors_str,
               $publication_date,
               $title,
               $sitename,
               $permalink
           );
   
           // Agregar el botón de copia al portapapeles
           $cita .= '<button class="btn-copiar" data-clipboard-text="' . esc_attr($cita) . '" style="background: #f7f7f7; color: #7DC22B; border: none; cursor: pointer; font-size: 14px; padding: 8px 16px; position: absolute; top: -35px; right: 0; z-index: 1;">Copy</button>';
   
           // Agregar el script JavaScript para Clipboard.js utilizando wp_add_inline_script
           $cita .= '<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.8/clipboard.min.js"></script>';
           $cita .= '<script>
               document.addEventListener("DOMContentLoaded", function() {
                   new ClipboardJS(".btn-copiar").on("success", function(e) {
                       alert("Texto copiado al portapapeles");
                       e.clearSelection();
                   });
               });
           </script>';
   
           return '<div class="mi-cita" style="color: #000000; position: relative;">' . $cita . '</div>';
       }
       ```
   
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fcreate-shortcode-for-apa-citation-format%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 1 replies (of 1 total)

 *  Plugin Support [Riza Maulana Ardiyanto](https://wordpress.org/support/users/rizaardiyanto/)
 * (@rizaardiyanto)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/create-shortcode-for-apa-citation-format/#post-17288896)
 * Hi [@ppantaleo](https://wordpress.org/support/users/ppantaleo/)
 * Thanks for using PublishPress Authors.
 * In this case, troubleshooting the custom code directly is necessary. However,
   please note that troubleshooting custom code falls outside of our support policy.
 * I recommend consulting with a developer or a coding expert who can provide personalized
   assistance with the specific implementation you’re working on. They’ll be better
   equipped to delve into your codebase and help you achieve the desired citation
   format.
 * Thanks,

Viewing 1 replies (of 1 total)

 The topic ‘Create shortcode for APA citation format’ is closed to new replies.

 * ![](https://ps.w.org/publishpress-authors/assets/icon-256x256.png?rev=3391318)
 * [Co-Authors, Multiple Authors and Guest Authors in an Author Box with PublishPress Authors](https://wordpress.org/plugins/publishpress-authors/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/publishpress-authors/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/publishpress-authors/)
 * [Active Topics](https://wordpress.org/support/plugin/publishpress-authors/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/publishpress-authors/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/publishpress-authors/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Riza Maulana Ardiyanto](https://wordpress.org/support/users/rizaardiyanto/)
 * Last activity: [2 years, 8 months ago](https://wordpress.org/support/topic/create-shortcode-for-apa-citation-format/#post-17288896)
 * Status: resolved