Php 在“中显示附件”;“单一”;用于自定义帖子类型
我正在使用插件构建自定义帖子类型和自定义分类法,这很好用。现在我正试图显示某个帖子的内容,并将附件上传到该帖子(仅一个,不允许倍数),但我无法让它工作。这就是我在Php 在“中显示附件”;“单一”;用于自定义帖子类型,php,wordpress,Php,Wordpress,我正在使用插件构建自定义帖子类型和自定义分类法,这很好用。现在我正试图显示某个帖子的内容,并将附件上传到该帖子(仅一个,不允许倍数),但我无法让它工作。这就是我在single legislacion.php模板中所做的: <div class="legislacion-col-izq"> <div class="CajaIzq"> <?php if ( have_posts() ) : ?> <?php w
single legislacion.php
模板中所做的:
<div class="legislacion-col-izq">
<div class="CajaIzq">
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<h4><?php the_title(); ?></h4>
<?php endwhile; ?>
<?php endif; ?>
<?php
$args = array(
'order' => 'ASC',
'post_type' => 'attachment',
'post_parent' => the_ID(),
'post_status' => 'inherit',
'numberposts' => 1
);
$attachments = get_posts( $args );
if ( $attachments ) {
foreach ( $attachments as $attachment ) { ?>
<div class="BaseIco">
<a class="IcoDescargas" href="<?php echo wp_get_attachment_url( $attachment->ID, true ); ?>">
<img src="<?php echo get_template_directory_uri(); ?>/images/ico_descargas.png"><br>
Descargar PDF
</a>
</div>
<?php }
}
?>
<div class="ModSuscrip">
<p class="A">¿Deseas ver comentarios y jurisprudencia sobre esta ley?</p>
<p class="B"><a href="#">Suscríbete a cualquiera de nuestros planes</a> y podrás ver material
complementario, enlaces, y mucho más para enreiquecer tu investigación</p>
</div>
<?php echo do_shortcode( '[toc label="Índice por Títulos"]' ) ?>
</div>
</div>
<div class="legislacion-col-der">
<div class="CajaInfo">
<div class="titulo">¿Estás buscando una palabra o frase en particular?</div>
Recuerda que puedes usar la función de búsqueda de tu navegador (Ctrl + F o Command + F)
</div>
<div class="CajaContenido">
<h1 class="titulo"><?php the_title(); ?></h1>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php $options = get_option( 'responsive_theme_options' ); ?>
<?php if ( $options['breadcrumb'] == 0 ): ?>
<?php echo responsive_breadcrumb_lists(); ?>
<?php endif; ?>
<div id="post-<?php the_ID(); ?>">
<div class="post-entry">
<?php the_content( __( 'Read more ›', 'responsive' ) ); ?>
<?php wp_link_pages( array(
'before' => '<div class="pagination">' . __( 'Pages:',
'responsive' ),
'after' => '</div>'
) ); ?>
</div>
<!-- end of .post-entry -->
<?php if ( comments_open() ) : ?>
<div class="post-data">
<?php the_tags( __( 'Tagged with:', 'responsive' ) . ' ', ', ', '<br />' ); ?>
<?php the_category( __( 'Posted in %s', 'responsive' ) . ', ' ); ?>
</div><!-- end of .post-data -->
<?php endif; ?>
<div class="post-edit"><?php edit_post_link( __( 'Edit', 'responsive' ) ); ?></div>
</div><!-- end of #post-<?php the_ID(); ?> -->
<?php comments_template( '', true ); ?>
<?php endwhile; ?>
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<?php if ( function_exists( 'wp_paginate' ) ) {
wp_paginate();
} ?>
<?php endif; ?>
<?php else : ?>
<h1 class="title-404"><?php _e( '404 — Fancy meeting you here!', 'responsive' ); ?></h1>
<p><?php _e( 'Don't panic, we'll get through this together. Let's explore our options here.',
'responsive' ); ?></p>
<h6><?php printf( __( 'You can return %s or search for the page you were looking for.', 'responsive' ),
sprintf( '<a href="%1$s" title="%2$s">%3$s</a>',
esc_url( get_home_url() ),
esc_attr__( 'Home', 'responsive' ),
esc_attr__( '← Home', 'responsive' )
) );
?></h6>
<?php get_search_form(); ?>
<?php endif; ?>
</div>
</div>
?是否有任何法律责任
y podrás ver材料
补充、补充和调查
因为您使用的是
ID(),它生成了一个回音
,它误解了您的参数
使用获取\u ID()
应该可以做到这一点