我正在尝试在我的主页上显示自定义后期类型的网格。我在WordPress中使用genesis框架。我在存档页面上正确运行了CPT存档网格,但是当我在主页上使用代码时,它没有显示任何帖子。
Set fso = CreateObject("Scripting.FileSystemObject")
Set F = fso.GetFolder("C:\Users\David Candy\Desktop\New Folder\Stories\Test")
If F.size > 2^30 Then
Set rs = CreateObject("ADODB.Recordset")
With rs
.Fields.Append "Date", 7
.Fields.Append "Txt", 201, 5000
.Open
For Each Thing in f.files
.AddNew
.Fields("Date").value = thing.datelastmodified
.Fields("Txt").value = thing.path
.UpDate
Next
.Sort = "Date Desc"
Do While not .EOF
fso.deletefile .Fields("Txt").Value
msgbox f.size
If f.size < 2^30 then Exit Do
.MoveNext
Loop
End With
End If
非常感谢任何帮助。
谢谢
答案 0 :(得分:0)
回答我自己的问题...... MUHAHAHAHAHA
将'post_type' => 'projects'
添加到我的$args = arrray
并将while( have_posts() ): the_post();
更改为while ( $loop->have_posts() ): $loop->the_post();
作为参考&#34;按帖子类型查询&#34;在WordPress Post Types页面上,我能够在主页上获取所有自定义帖子类型的提取和过滤。
希望这可以帮助其他想要回答相同问题的人。
完整工作守则:
<?php
/**
* Home
*/
// Force full width content (optional)
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
//remove standard loop (optional)
remove_action( 'genesis_loop', 'genesis_do_loop' );
// Add our custom loop
add_action( 'genesis_loop', 'lp_filterable_portfolio' );
// Enqueue javascript
wp_enqueue_script( 'isotope', get_stylesheet_directory_uri() . '/js/isotope.pkgd.min.js', array( 'jquery' ), '1.5.25', true );
wp_enqueue_script( 'isotope_init', get_stylesheet_directory_uri() . '/js/isotopes_init.js', array( 'isotope' ), '', true );
/**
* Get Excerpt.
*
* @since 1.0
*
*/
function the_excerpt_max_charlength( $charlength ) {
$excerpt = get_the_excerpt();
$charlength++;
if ( mb_strlen( $excerpt ) > $charlength ) {
$subex = mb_substr( $excerpt, 0, $charlength - 5 );
$exwords = explode( ' ', $subex );
$excut = -( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) );
if ( $excut < 0 ) {
echo mb_substr( $subex, 0, $excut );
} else {
echo $subex;
}
echo '[...]';
} else {
echo $excerpt;
}
}
/**
* Output filterable portfolio items.
*
* @since 1.0
*
*/
function lp_filterable_portfolio() {
$args = array(
'post_type' => 'your_post_type', //Add your custom post type
'post_per_page' => 9999
);
$loop = new WP_Query( $args );
$terms = get_terms( 'your_taxonomy' ); // Add your custom taxonomy
$count = 0;
?>
<div class="archive-description">
<?php if( $terms ) { ?>
<ul id="portfolio-cats" class="filter clearfix">
<li><a href="#" class="active" data-filter="*"><span><?php _e('All', 'lp'); ?></span></a>
</li>
<?php
foreach ( $terms as $term ) {
echo "<li><a href='#' data-filter='.$term->slug'><span>$term->name</span></a></li>";
}
?>
</ul>
<!-- /portfolio-cats --><br/><br/>
<?php } ?>
<?php if( have_posts() ) { ?>
<div id="portfolio-wrap" class="clearfix filterable-portfolio">
<div class="portfolio-content">
<?php while ( $loop->have_posts() ): $loop->the_post(); ?>
<?php $count++; ?>
<?php $terms = get_the_terms( get_the_ID(), 'your_taxonomy' ); // Add your custom taxonomy ?>
<?php if ( has_post_thumbnail($post->ID) ) { ?>
<article class="portfolio-item col-<?php echo $count; ?> <?php if( $terms ) foreach ( $terms as $term ) { echo $term->slug .' '; }; ?>">
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
<?php echo genesis_get_image( array( size => 'lp-portfolio' ) ); ?>
<div class="portfolio-overlay">
<h3>
<?php the_title(); ?>
</h3>
<p>
<?php the_excerpt_max_charlength(50);?>
</p>
</div>
<!-- overlay -->
</a>
</article>
<?php } ?>
<?php endwhile; ?>
</div>
<!-- /themes-content -->
</div>
<!-- /themes-wrap -->
<?php } ?>
<?php wp_reset_postdata(); ?>
</div>
<?php
wp_reset_postdata();
}
genesis();