我想提取最新的 post 并嵌入其他 2 个第一个结果 posts?
I want to pull latest post and embed other 2 first result posts?
用户将同时search/submit。
<input id="user-submitted-title" name="user-submitted-title" type="text" value="" placeholder="<?php esc_attr_e('Search', 'usp'); ?>"<?php if (usp_check_required('usp_title')) echo $usp_required; ?> class="usp-input">
这个是wordpress插件的表格,只是一个标题,我只用那个。当用户按标题提交时,我还有其他代码可以通过其他代码将 post 添加到我的 wordpress 网站中。
我已经有一个查询:
<?php
include 'wp-load.php';
$args = array(
'post_type' => 'post',
'posts_per_page' => 1
);
$query = new WP_Query($args);
if($query->have_posts()):
$data = '';
while($query->have_posts()):$query->the_post();
$data .= '<h1 style="text-align: center; margin: 0; margin: 0px 0 10px 0px;">'.get_the_title().'</h1>';
$data .= '<div class="description">'.do_shortcode(get_the_content()).'</div>';
endwhile;endif;
echo $data; ?>
所以这个基本上显示了他们的或来自 wordpress 站点的最新 post 与 search/submit 按钮在同一页面上。
除此之外,我想完成它以获取并嵌入通过输入查询找到的其他网站 post 的内容,并将它们嵌入到上述网站之后。
我尝试了一些新查询,例如:
<?php
include 'wp-load.php';
$querys = new WP_Query('post_title='.get_the_title().'');
if($querys->have_posts()) : while($querys->have_posts()) : $querys->the_post();
if (has_post_thumbnail()) {
?>
<a href="<?php the_permalink(' ') ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail(); ?></a>
<?php
}
?>
<h2><a href="<?php the_permalink(' ') ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<?php
the_excerpt(); // or the_content(); for full post content
endwhile;endif;
?>
但是这个$querys = new WP_Query('post_title='.get_the_title().'');
好像不行。
这该怎么做?
另外,第二个查询对链接、外部循环不起作用,如何解决?
你试过了吗
$querys = new WP_Query('post_title="'.get_the_title().'"');
这个。
或者可能是这个
$querys = new WP_Query('s' => get_the_title()); // custom search query
用户将同时search/submit。
<input id="user-submitted-title" name="user-submitted-title" type="text" value="" placeholder="<?php esc_attr_e('Search', 'usp'); ?>"<?php if (usp_check_required('usp_title')) echo $usp_required; ?> class="usp-input">
这个是wordpress插件的表格,只是一个标题,我只用那个。当用户按标题提交时,我还有其他代码可以通过其他代码将 post 添加到我的 wordpress 网站中。
我已经有一个查询:
<?php
include 'wp-load.php';
$args = array(
'post_type' => 'post',
'posts_per_page' => 1
);
$query = new WP_Query($args);
if($query->have_posts()):
$data = '';
while($query->have_posts()):$query->the_post();
$data .= '<h1 style="text-align: center; margin: 0; margin: 0px 0 10px 0px;">'.get_the_title().'</h1>';
$data .= '<div class="description">'.do_shortcode(get_the_content()).'</div>';
endwhile;endif;
echo $data; ?>
所以这个基本上显示了他们的或来自 wordpress 站点的最新 post 与 search/submit 按钮在同一页面上。
除此之外,我想完成它以获取并嵌入通过输入查询找到的其他网站 post 的内容,并将它们嵌入到上述网站之后。
我尝试了一些新查询,例如:
<?php
include 'wp-load.php';
$querys = new WP_Query('post_title='.get_the_title().'');
if($querys->have_posts()) : while($querys->have_posts()) : $querys->the_post();
if (has_post_thumbnail()) {
?>
<a href="<?php the_permalink(' ') ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail(); ?></a>
<?php
}
?>
<h2><a href="<?php the_permalink(' ') ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<?php
the_excerpt(); // or the_content(); for full post content
endwhile;endif;
?>
但是这个$querys = new WP_Query('post_title='.get_the_title().'');
好像不行。
这该怎么做?
另外,第二个查询对链接、外部循环不起作用,如何解决?
你试过了吗
$querys = new WP_Query('post_title="'.get_the_title().'"');
这个。
或者可能是这个
$querys = new WP_Query('s' => get_the_title()); // custom search query