我正在使用wp paginavi对我的帖子进行分页,到目前为止,我已经能够在存档和类别页面上做到这一点,但在我的自定义页面模板上却无法使用。 我已经检查了与自定义帖子类型相关的问题的可能性,但没有发现任何关系。我认为这可能与页面模板的wordpress结构有关。
我的代码有什么问题?
import wx
class Example(wx.Frame):
def __init__(self, title):
super().__init__(None, title=title)
self.panel = wx.Panel(self)
self.prefix = "Prefix-Alpha"
self.initUI()
self.Centre()
def initUI(self):
sizer = wx.GridSizer(3, 1, 10, 10)
self.create_button1(sizer)
self.create_button2(sizer)
self.create_button3(sizer)
self.panel.SetSizer(sizer)
def create_button1(self, sizer):
button1 = wx.Button(self.panel, label=self.prefix + "-Button 1", name="-Button 1")
sizer.Add(button1, 1, wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
def create_button2(self, sizer):
button2 = wx.Button(self.panel, label=self.prefix + "-Button 2", name="-Button 2")
sizer.Add(button2, 1, wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
def create_button3(self, sizer):
button3 = wx.Button(self.panel, label="Change Prefix")
sizer.Add(button3, 1, wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
button3.Bind(wx.EVT_BUTTON, self.on_change_prefix)
def on_change_prefix(self, e):
if self.prefix == "Prefix-Alpha":
self.prefix = "Prefix-Beta"
else:
self.prefix = "Prefix-Alpha"
children = self.panel.GetChildren()
for child in children:
if child.ClassName == "wxButton":
if child.Name.startswith("-Button"):
child.SetLabel(self.prefix+child.Name)
if __name__ == '__main__':
app = wx.App()
Example("Simple Example").Show()
app.MainLoop()
答案 0 :(得分:0)
我在查询上做了一些工作,它确实起作用了!
<ul class="artlist">
<?php $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$custom_args = array(
'post_type' => 'post',
// 'post_type' => array('product_gold', 'product_tool'),
'posts_per_page' => 1,
'paged' => $paged
);
// custom query
$recent_posts = new WP_Query( $custom_args );
$thumbnail = wp_get_attachment_url(get_post_thumbnail_id($post->ID), 'gallery-thumb');
if(empty($thumbnail)) $thumbnail = APP_URL . "images/cms/no-image.png";
// check that we have results
if($recent_posts->have_posts()) : ?>
<?php while ($recent_posts->have_posts() ) : $recent_posts->the_post(); ?>
<li>
<a href="<?php echo get_permalink(); ?>">
<div class="img" style="background-image: url(<?php echo $thumbnail; ?>);">
<img src="<?php echo APP_URL ?>images/top/mask_sp.png" alt="" class="mask">
</div>
<!-- .img -->
<div class="text">
<h3 class="tittle pc">
<?php if( get_field('b-number') ): ?>
<span class="number">No.<?php the_field('b-number'); ?></span>
<?php endif; ?>
<?php echo mb_strimwidth(get_the_title(), 0, 22, '...'); ?>
</h3>
<h3 class="tittle sp excpt">
<?php if( get_field('b-number') ): ?>
<span class="number">No.<?php the_field('b-number'); ?></span>
<?php endif; ?>
<br>
<?php echo mb_strimwidth(get_the_title(), 0, 18, '...'); ?>
</h3>
<h3 class="tittle sp ip5">
<?php if( get_field('b-number') ): ?>
<span class="number">No.<?php the_field('b-number'); ?></span>
<?php endif; ?>
<br>
<?php echo mb_strimwidth(get_the_title(), 0, 15, '...'); ?>
</h3>
<div class="down">
<div class="dd">
<p class="price"><?php echo the_field('a-price'); ?><?php echo the_field('b-price'); ?> 円<span class="smalls">(税別)</span></p>
<span class="more pc">詳細へ</span>
<span class="more sp">詳細を見る</span>
</div>
</div>
</div>
</a>
</li>
<?php endwhile; ?>
</ul>
<?php endif;
echo '<div class="pagination">';
if(function_exists('wp_pagenavi')) { wp_pagenavi(array( 'query' => $recent_posts )); }
echo '</div>';
wp_reset_postdata();
?>