• Resolved ppantaleo

    (@ppantaleo)


    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/.

    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/.

    The same thing happens in Multiplautores. I don’t have a published example yet.

    The code is:

    // 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 to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Support Riza Maulana Ardiyanto

    (@rizaardiyanto)

    Hi @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.