0

ワードプレスのスクリプトを変更したい。を使用してすべてのメタ投稿を取得したいget_post_meta。しかし、から始めてそれを行う方法$user_ID。つまり、私はユーザー ID を持っているだけで、彼のメタ投稿を取得したいのですget_post_meta()

たとえば、この例は私が必要とするものに近いですが、投稿が見つからず、0 件の投稿が見つかりました。

<?php query_posts('author=32'); ?>
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php endwhile; endif; ?>
4

3 に答える 3

2

global $current_userおよび関数を使用して、引数get_currentuserinfo()のユーザー ID を設定できます。query_posts()

<?php
// get the current user and populate
global $current_user;
get_currentuserinfo();

// use the current user ID as the author and query for posts
$args = array( 'author' => $current_user->ID );
query_posts($args);
?>
<?php if ( have_posts() ): while( have_posts() ): the_post(); ?>
    <?php the_title(); ?>
<?php endwhile; endif; ?>
于 2013-05-05T21:21:07.703 に答える
0

これを試して

<?php
// The Query
query_posts('author=<id>');
// The Loop
if ( have_posts() ) : while ( have_posts() ) : the_post();
"<a href="the_permalink();">"the_title();"</a>";
endwhile;
// Reset Query
wp_reset_query();
?>
于 2013-05-05T19:40:47.900 に答える
-2

Query() 関数で author パラメーターを使用できます。あなたはここでそれを見つけるかもしれません

于 2013-05-05T20:36:16.590 に答える