在Wordpress中的同一页面上显示搜索结果

时间:2016-03-10 12:37:52

标签: php wordpress search

我正在尝试创建一个包含搜索表单的Wordpress页面,但我无法在同一页面上显示搜索结果。我已经看到我应该在我的php文件中包含一个Wordpress循环,但我无法弄清楚如何。

这是我的搜索表单:

//Flatten complex object (of type ie. Order) and convert it to EntityProperty Dictionary
 Dictionary<string, EntityProperty> flattenedProperties = EntityPropertyConverter.Flatten(order);

// Create a DynamicTableEntity and set its PK and RK
DynamicTableEntity dynamicTableEntity = new DynamicTableEntity(partitionKey, rowKey);
dynamicTableEntity.Properties = flattenedProperties;

// Write the DynamicTableEntity to Azure Table Storage using client SDK

//Read the entity back from AzureTableStorage as DynamicTableEntity using the same PK and RK
DynamicTableEntity entity = [Read from Azure using the PK and RK];

//Convert the DynamicTableEntity back to original complex object.
 Order order = EntityPropertyConverter.ConvertBack<Order>(entity.Properties);

search4.php文件就是这个:

[photo saveInBackgroundWithBlock:^(BOOL succeeded, NSError * _Nullable error) {
    if (succeeded) {
        NSLog(@"%@",photo.objectId);
        _PFObjectId = photo.objectId;
        //You should not alloc it again once the view controller is pushed or presented .If it is already in stack
        AddProductDetailsViewController *sendData = (AddProductDetailsViewController *)[[self.navigationController viewControllers] lastObject];

        //instead of sending object Directly like this sendData.objectId = photo.objectId  create a method and call after completion
        [sendData pushObjectId:photo.objectId];
    }
}];

1 个答案:

答案 0 :(得分:2)

这是我做的:

自定义表单:

<form role="search" method="GET" id="searchform" action="<?php echo get_permalink(); ?>">
    <input type="text" name="search" id="search" value="search">

    <input type="submit" id="searchsubmit" value="Search" />
</form>

在页面上我想要搜索结果:

我在codex上做了WP_query之类的事情 并将$args更改为:

if( isset( $_REQUEST['search'] ) ){
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
        'paged'           => $paged,
        'posts_per_page'  => 16, //or any number
        'post_type'       => 'post', //or your custom post type if needed
        's'               => $_REQUEST[ 'search' ]
    );
}