php Mostrar选择con post de lamismaclassíamenosel mismo

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Mostrar选择con post de lamismaclassíamenosel mismo相关的知识,希望对你有一定的参考价值。

<select class="form-control" id="cat">
<option><?php _e( 'Conoce otros modelos de la marca', 'parraarango' ); ?></option>
<?php
$categories = get_the_terms( $post->ID, 'categoria_modelo' );
$args = array(
  'post_type'=>'modelo_custom',
  'posts_per_page' => -1,
  'post__not_in' => array( $post->ID ),
  'tax_query' => array(
    array(
      'taxonomy' => 'categoria_modelo',
      'field'    => 'term_id',
      'terms'    =>  $categories[0]->term_id,
    ),
  ),

);
$myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post );
?>
<option value="<?php the_permalink(); ?>"><?php the_title(); ?></option>
<?php endforeach;
wp_reset_postdata();
?>
</select>
<script>
  // Cambio select modelos Nuevos

var dropdown = document.getElementById("cat");
function onCatChange() {
  location.href = dropdown.options[dropdown.selectedIndex].value;
}
dropdown.onchange = onCatChange;
</script>

以上是关于php Mostrar选择con post de lamismaclassíamenosel mismo的主要内容,如果未能解决你的问题,请参考以下文章

html [notificaciones jquery con uso de cookies] para mostrar notificaciones x usuario y poder cerrar

php Mostrar produtos fora de estoque no final em Woocommerce

php Mostrar produtos fora de estoque no final em Woocommerce

php Mostrar els items de un camp en un sol array。

markdown Mostrar una respuesta por defecto al mostrar la pregunta(opc simples con otra)

sh Mostrar un json remoto en local con ssh。