开发者

Make Search and Archives match homepage

I have my homepage http://www.faberunashop.com set up as a directory. When you click on the post image, it takes you over to the artists site. Here is the code that I used to make this happen by adding it to the functions.php:

function print_post_title() {
    global $post;
    $thePostID = $post->ID;
    $post_id = get_post($thePostID);
    $title = $开发者_JS百科post_id->post_title;
    $perm  = get_permalink($post_id);
    $post_keys = array(); $post_val  = array();
    $post_keys = get_post_custom_keys($thePostID);

    if (!empty($post_keys)) {
      foreach ($post_keys as $pkey) {
            if ($pkey=='url1' || $pkey=='title_url' || $pkey=='url_title') {
              $post_val = get_post_custom_values($pkey);
            }
      }
      if (empty($post_val)) {
            $link = $perm;
      } else {
            $link = $post_val[0];
      }
    } else {
      $link = $perm;
    }
    echo '<h2><a href="'.$link.'" rel="bookmark" title="'.$title.'">'.$title.'</a></h2>';
}

Now I want to do the same to my search and archive page. What do I adjust to make them behave the same?


I suppose that you use WordPress.

In that case you can change the layout and the behavior of your search results by creating a file with name search.php into your theme for your search results, and another file for archives that called archives.php.

For more information about Template Hierarchy for WordPress you can find here http://codex.wordpress.org/Template_Hierarchy

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜