ThemeShaper Forums » Thematic

[closed]

Editing thematic_searchloop() and search results page

(13 posts)
  • Started 4 years ago by davaobase
  • Latest reply from middlesister
  • This topic is not resolved
  1. I've been scouring forums and search engines, but I can't get the exact solution that I want.

    I'm using Gallery (child theme of Thematic), and am not satisfied with the search results page. See this as an example: http://www.filmsteak.com/?s=shrek&searchsubmit=Search

    Where exactly do I find the original contents of the thematic_searchloop() function? I want to see the original content, before I edit the said function through my child theme's functions.php file.

    Any form of help will be much appreciated.

    Posted 4 years ago #
  2. Hi,

    the original content is created by thematic_search_loop() which can be found in /library/extensions/content-extensions.php.

    Chris

    Posted 4 years ago #
  3. Thanks for the prompt reply, Chris.

    How do I remove / change the contents of this specific function, from my child theme's functions.php?

    Posted 4 years ago #
  4. Hi,

    would be this code for your child theme's functions.php:

    // remove the standard search loop
    function remove_search_loop() {
    	remove_action('thematic_searchloop', 'thematic_search_loop');
    }
    add_action('wp', 'remove_search_loop');
    
    // create your own search loop
    function my_search_loop() {
    // Your content goes in here
    }
    add_action('thematic_searchloop', 'my_search_loop');

    Chris

    Posted 4 years ago #
  5. Hi there!

    can anyone tell me, which code i need to put in that loop show result page like other pages (with thumbnails)

    i use Gallery Theme (thanks Chris!)
    sorry for my English)

    Posted 4 years ago #
  6. You need to put this code in the function.php file of the Gallery theme folder, to get search results looking like index page :

    // remove the standard search loop
    function remove_search_loop() {
    	remove_action('thematic_searchloop', 'thematic_search_loop');
    }
    add_action('wp', 'remove_search_loop');
    // create your own search loop
    function my_search_loop() {
    // Your content goes in here
      global $post;
      /* Count the number of posts so we can insert a widgetized area */ $count = 1;
      while ( have_posts() ) : the_post() ?>
    
    			<div id="post-<?php the_ID() ?>" class="<?php
    			thematic_post_class();
    			if(function_exists('p75GetVideo')){
    		    if(p75GetVideo($post->ID)){
    				  echo " video";
    				}
    			}
    			?>">
    				<div class="entry-content">
    					<?php childtheme_post_header() ?>
                        <a>"><span class="slide-title"><?php echo the_title(); ?></span>
                        <img class="thumbnail" src="<?php if(get_post_meta($post->ID, 'thumbnail', $single = true)){echo get_post_meta($post->ID, 'thumbnail', $single = true);} else{bloginfo('url'); echo "/wp-content/themes/gallery/images/thumbnail-default.jpg";} ?>" width="125" height="125" alt="<?php echo the_title() ?>" /></a>
    				</div>
    			</div><!-- .post -->
    
        <?php comments_template();
    
        if ($count==$thm_insert_position) {
          get_sidebar('index-insert');
        }
        $count = $count + 1;
      endwhile;
    }
    add_action('thematic_searchloop', 'my_search_loop');
    Posted 4 years ago #
  7. wacwac
    Member

    Can I exclude the pages from this search?

    Posted 3 years ago #
  8. wacwac, try adding this to your child theme's functions.php:

    function my_custom_search_($query) {
            if ($query->is_search) {
            $query->set('post_type', 'post');
                                    }
            return $query;
    }
    add_filter('pre_get_posts','my_custom_search');
    Posted 3 years ago #
  9. wacwac
    Member

    I have added your code in functions.php of gallery theme (Chris wallace) but I have this error:
    Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'my_custom_search' was given in C:\Program Files\EasyPHP5.2.10\www\ravenna\wp-includes\plugin.php on line 473

    In which point of code I must insert your code?

    (sorry for my english)

    Posted 3 years ago #
  10. guitaremo311
    Member

    Can someone please check MasterNoun's code? I think there may be a simple error in it, but I cannot see what's wrong (I'm a noob with php).

    // remove the standard search loop
    function remove_search_loop() {
    	remove_action('thematic_searchloop', 'thematic_search_loop');
    }
    add_action('wp', 'remove_search_loop');
    // create your own search loop
    function my_search_loop() {
    // Your content goes in here
      global $post;
      /* Count the number of posts so we can insert a widgetized area */ $count = 1;
      while ( have_posts() ) : the_post() ?>
    
    			<div id="post-<?php the_ID() ?>" class="<?php
    			thematic_post_class();
    			if(function_exists('p75GetVideo')){
    		    if(p75GetVideo($post->ID)){
    				  echo " video";
    				}
    			}
    			?>">
    				<div class="entry-content">
    					<?php childtheme_post_header() ?>
                        <a>"><span class="slide-title"><?php echo the_title(); ?></span>
                        <img class="thumbnail" src="<?php if(get_post_meta($post->ID, 'thumbnail', $single = true)){echo get_post_meta($post->ID, 'thumbnail', $single = true);} else{bloginfo('url'); echo "/wp-content/themes/gallery/images/thumbnail-default.jpg";} ?>" width="125" height="125" alt="<?php echo the_title() ?>" /></a>
    				</div>
    			</div><!-- .post -->
    
        <?php comments_template();
    
        if ($count==$thm_insert_position) {
          get_sidebar('index-insert');
        }
        $count = $count + 1;
      endwhile;
    }
    add_action('thematic_searchloop', 'my_search_loop');
    Posted 3 years ago #
  11. I think the error in the code is with the line:

    <a>"><span class="slide-title"><?php echo the_title(); ?></span>

    It should read...

    <a href="<?php echo the_permalink() ?>"><span class="slide-title"><?php echo the_title(); ?></span>

    Posted 3 years ago #
  12. Did anyone ever get this resolved? I too would like to clean up my search results page without hacking Thematic core and would appreciate it if someone solved this. I have tried everything suggested here and more but no joy yet.

    Posted 2 years ago #
  13. middlesister
    Member

    What do you want do do?

    This thread is a bit old, and the OP doesn't even seem to be using the Gallery theme anymore. While the code above should work fine (fixing the error like kodamapixel says) you can also use a childtheme_override function. Just create a

    function childtheme_override_search_loop() {
        // Your content goes in here
    }

    in your functions.php file and you are good to go.

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.