0

Tengo una duda, estoy trabajando en wordpress y he creado un snippet para extraer datos de una url con datos xlm. Lo que nose es como hacer para que cuando pinche en la etiqueta <a>a</a> me abra una nueva pagina. Aqui os paso el código.

add_shortcode( 'lista_coches', 'lista_coche' );

function lista_coche(){
        // URL DE ACCESO AL XML
    $url = "https://carspark.dealerk.es/myPortalXML/index?myPortalXMLkey=0fc90c15-32eb-40a5-9b21-f13ec1a6b77e";

    // Carga de Archivo XML
    $xml = simplexml_load_file($url);

    // Vamos a recorrer el array de cars
    $cars = $xml->car;
    foreach ($cars as $car) {
        

        $car_name = (string) $car -> subTitle;
        $car_ano = (string) $car -> registrationDate;
        $car_descripcion = (string) $car -> description;
        $car_km = (string) $car -> km;
        $car_carroceria = (string) $car -> bodyType;
        $car_cambio = (string) $car -> gear -> gearType;
        $car_puertas = (string) $car -> doors;
        $car_asientos = (string) $car -> seats;
        $car_cilindrada= (string) $car ->cc;
        $car_caballos = (string) $car -> hp;
        $car_color = (string) $car -> exterior -> color;
        $car_combustible = (string) $car -> fuelType;
        $car_precioContado = (string) $car -> prices -> priceB2c;
        $car_precioFinanciado = (string) $car -> prices -> financedPrice;
        $car_portada = (string) $car -> images -> image;
        
    
     

         
        echo '
        
        <div class="card">
            <a href="#" class="open-popup card-a">
                
                    <img src="'.$car_portada.'" alt="imagen_coche">
                
                <div class="card-info">
                    <h1>'.$car_name.'</h1>
                    <p class="descripcion"><span>'.$car_combustible.'</span>|<span>'.$car_ano.'</span>|<span>'.$car_km.'km</span>|<span>'.$car_caballos.'cv</span></p>
                    <div class="card-precio">
                        <div class="contado"><p>Precio al contado</p><h3>'.number_format($car_precioContado).'€</h3></div>
                        <div class ="financiado"><p>Precio financiado</p><h3>'.number_format($car_precioFinanciado).'€</h3></div>
                    </div>
                </div>
            </a>
        </div>
        <div hidden>
           <h1>Coche</h1>
        </div>
        ';
       
    }
}

1 respuesta 1

0

En caso de duda, siempre cae bien leer la documentación de sitios confiables.

target

Where to display the linked URL, as the name for a browsing context (a tab, window, or ). The following keywords have special meanings for where to load the URL:

_self: the current browsing context. (Default)

_blank: usually a new tab, but users can configure browsers to open a new window instead.

_parent: the parent browsing context of the current one. If no parent, behaves as _self.

_top: the topmost browsing context (the "highest" context that's an ancestor of the current one). If no ancestors, behaves as _self.

Como quien dice, target='_blank' abre en una nueva ventana/pesataña según le parezca a tu navegador.

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.