Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 引导网格在wordpress中显示用户选择的帖子_Php_Wordpress_Twitter Bootstrap_Wordpress Theming - Fatal编程技术网

Php 引导网格在wordpress中显示用户选择的帖子

Php 引导网格在wordpress中显示用户选择的帖子,php,wordpress,twitter-bootstrap,wordpress-theming,Php,Wordpress,Twitter Bootstrap,Wordpress Theming,我正在尝试开发我的第一个wordpress主题,它应该显示一个包含4个图像的引导网格。这些图像中的每一个都应该链接到一个特定的帖子页面,用户可以在wp admin部分选择该页面 它还应该显示用户输入的一些文本和链接 <div class="container"> <div class="row"> <div id ="show" class="col-xs-3 col-sm-1 col-md-1" ><img src="feat

我正在尝试开发我的第一个wordpress主题,它应该显示一个包含4个图像的引导网格。这些图像中的每一个都应该链接到一个特定的帖子页面,用户可以在wp admin部分选择该页面

它还应该显示用户输入的一些文本和链接

<div class="container">
    <div class="row">

        <div id ="show" class="col-xs-3 col-sm-1 col-md-1" ><img src="featured image of post user selected" alt="description of post user selected"/></div>
        <div id ="show" class="col-xs-3 col-sm-1 col-md-1" ><img src="featured image of post user selected" alt="description of post user selected"/></div>
        <div id ="show" class="col-xs-3 col-sm-1 col-md-1" ><img src="featured image of post user selected" alt="description of post user selected"/></div>
        <div id ="show" class="col-xs-3 col-sm-1 col-md-1" ><img src="featured image of post user selected" alt="description of post user selected"/></div>

        <div class="col-xs-12 col-sm-4 col-md-4"><p>some text the user specifys</p></div>
        <div class="col-xs-12 col-sm-3 col-md-3"><a href="a link the user specifys">my link</a></div>

    </div>
</div>

用户指定的某些文本

我已经研究过创建一个循环,但我不想简单地循环我的帖子并显示前4个。用户必须能够选择在每个图像中显示哪些帖子。这可能吗?

解决方案在WP\U查询中插入HTML 我给你做了一些快速的东西,如果你使用这段代码,你可以在正确的位置插入HTML:

<?php

$lifestyle_cat = array(
    'category_name' => 'home',
    'showposts' => 4,
    'post_type' => 'post',
    'post_status' => 'publish',
    'orderby' => 'date',
    'order' => 'DESC'
);

$lifestyle_query = new WP_Query( $lifestyle_cat );
if ( $lifestyle_query->have_posts()) {
    $i = 0; 
    while ( $lifestyle_query->have_posts()) {
       $i++;
       $lifestyle_query->the_post(); ?>  
       <div id ="show" class="col-xs-3 col-sm-1 col-md-1" > 
       //title
       <?php  the_title();
        if (has_post_thumbnail()) { 
            // only print out the thumbnail if it actually has one
            the_post_thumbnail('thumbnail');
        }
    ?></div><?php
    } 
} 
?>

//头衔


您可以这样做,但在wordPress中,您基本上使用php模板,而您只是显示HTML。。。我建议您阅读文档:我知道您使用PHP,但到目前为止,我所能找到的只是在网格中显示所有post项。我已经展示了HTML,因为我认为这是描述我正在尝试做的事情的最简单的方式!因此,在php模板中插入此html,并使用wp_查询调整帖子数量。例如(在while循环中,您需要放置这些html元素),事情是。。我不想得到排名前十的帖子。。。我希望用户能够选择在网格中显示的特定帖子。这可能吗?你可以按标签或类别找到帖子。。。只需创建一个“特色”标签或类别,通过wp_查询,您就可以过滤它们了。谢谢。但是,这难道不只是显示类别“主页”中的前4篇文章,而不是允许用户选择每篇文章上显示的文章吗?你可以使用customfields,在那里你可以设置文章的顺序,但还有一个ACP插件,你可以在其中嵌入主题并创建新的字段来设置顺序:这个问题解决了吗?你能结束这个问题吗?马克会被解决吗?