所以,我有以下内容来显示post loop(wordpress):
方法A(工作正常)
<?php
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} elseif ( get_query_var('page') ) {
$paged = get_query_var('page');
} else {
$paged = 1;
}
$args = array(
'post_type' => 'post',
'paged'=>$paged,
'posts_per_page' => 7,
'orderby' => 'date',
'order' => 'DESC'
);
$loop = new WP_Query( $args );
$id = get_the_ID();
global $paged;
while ( $loop->have_posts() ) : $loop->the_post();
?>
Posts go here
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<nav id="rh_nav_below">
<ul>
<li class="rh_nav_previous"><?php previous_posts_link( '« PREV', $loop->max_num_pages) ?></li>
<li class="rh_nav_next"><?php next_posts_link( 'NEXT »', $loop->max_num_pages) ?></li>
</ul>
</nav>
现在在作者页面中,以下用于显示帖子(单个帖子):
方法B(工作正常)
<?php rewind_posts(); while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>
我一直在尝试将作者帖子(方法b)更改为方法A格式,因此我可以控制帖子数量,orderby等。
以下是我的尝试:
<?php
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} elseif ( get_query_var('page') ) {
$paged = get_query_var('page');
} else {
$paged = 1;
}
$rhp_author_profile_id = get_the_author_id();
$args = array(
'post_type' => 'post',
'paged'=>$paged,
'posts_per_page' => 7,
'orderby' => 'date',
'order' => 'DESC',
'author ' => $rhp_author_profile_id
);
$loop = new WP_Query( $args );
$id = get_the_ID();
global $paged;
while ( $loop->have_posts() ) : $loop->the_post();
?>
Posts show here.
但是,我只是在每个其他作者上发布管理员的帖子。
我做错了什么?
由于
答案 0 :(得分:1)
试试这个
#!/usr/bin/perl
use strict;
use DBI;
use DBD::ODBC;
BEGIN {
$ENV{SYBASE} = "/sybase";
}
my $user = "";
my $passwd = "";
my $server = "";
my $database = "pubs1";
my $port = "5000";
my $data_source = "DBI:ODBC:DRIVER={Adaptive Server Enterprise};server=$server;port=$port;database=$database;";
my @drivers = DBI->available_drivers;
print join(", ", @drivers), "\n";
my $dbh = DBI->connect($data_source, $user, $passwd)
or die "Can't connect to $data_source: $DBI::errstr";
my $statement = "SELECT * FROM <table_name>";
my @row = $dbh->selectrow_array($statement);
print "@row\n";
$dbh->disconnect;