1

我有一个客户的 WordPress 网站。他拥有一家音像店,我为他创建了一个网站来更新电影列表,通常只是“本周新”电影。

我使用 PodCMS 作为他上传电影然后显示它们的简单方法。他甚至不需要创建帖子。效果很好,这是一个很棒的扩展,我只是遇到了一些问题。

Pod 有一个字段,您可以在其中插入发布日期。2010-04-20
然后有一个 Pod 页面/模板组合,它调用具有特定发行日期的电影,如下所示:
$date = pods_url_variable('last');
然后他只是用 slug 创建一个空白的 WP 页面 2010-04-20
所以当你打开那个页面时, Pod 页面/模板读取该 slug 并呈现相应电影的列表。

我的问题:我需要这些是可搜索的。这可能吗。

我也愿意接受有关使该站点正常运行的其他方法的建议。我需要它像那样简单。上传一些电影并创建一个新页面。然后剩下的就自动完成了。

4

2 回答 2

2

A PodsCMS search is nothing more than a mySQL table search for the search term. You can search the title, body, pretty much anything. Here's an example:

Note: I'm using "whatever" as the pod info. I'm also forming a string that goes into the $where position which comprises the various pods variables I want to search on. Also, I'm assuming pagination using the Pods pagination controls but I want that variable carried across the pages so I can offset.

<?php

$search_term = $_GET["s"];
$paged = get_query_var('paged');
$page_number = $_GET['pg'];

?>

<h1>
      Results for "<?php echo $search_term; ?>"<?php if($page_number > 1){ ?> (Continued)<?php } ?><?php if($paged > 1){ ?> (Continued)<?php } ?>
  </h1>

  <?php if($paged <= 1){ ?>
  <h2>Results in Whatever...</h2>

      <?php
            $whateverSentence = "(t.name LIKE '%" .$search_term. "%') || (t.whatever LIKE '%" .$search_term. "%')";
            $whatever = new Pod('whatever');
            $whatever->findRecords($orderby = 't.whatever DESC', $rows_per_page = 5, $where = $whateverSentence, $sql = null);
            $total_whatever = $whatever->getTotalRows();
      ?>
      <?php if( $total_whatever >0 ) : ?>
      <?php while ( $whatever->fetchRecord() ) : ?>
      <?php
            // Set Variables
            $whatever_ID = $whatever->get_field('id');
            $whatever_Permalink = $whatever->get_field('slug');
            $whatever_Name = $whatever->get_field('name');

    ?>

Code that echos the pods variables and represents the search result

<?php endwhile ?>

<?php else: ?>

<p>Sorry, no results found for that search.</p>

<?php endelse; endif ?>
<?php echo $whatever->getPagination($label = '<span class="pagination-text">Go to page:</span>'); ?>


<?php } ?>
于 2011-02-25T17:26:47.447 回答
0

所以你需要 WordPress 页面内容 - 电影列表 - 是可搜索的?

WP 本身不会搜索页面,但会使用WordPress › Search Everything « WordPress Plugins并使用 WordPress 更好地搜索› Relevanssi « WordPress Plugins

于 2010-04-21T19:29:31.810 回答