Forum Replies Created

Viewing 15 replies - 1 through 15 (of 23 total)
  • Thread Starter stephanium

    (@stephanium)

    I can’t provide an URL, because the site isn’t reachable from the internet.
    I’m using a domain user, which is Owner of the new and old database.
    The database is hostet on a Server not localhost. The new database is hosted on the same server like the old database.
    I’m not using a shared hosting system.
    When I Change wp-config back to the original database the site works again.
    I migrated all tables with all data of the old database. The table names still are the same.

    When I try to call my blog with the new database, it tries about 2 minutes to load the page and then in IE following error appears:
    This page can’t be displayed
    ?Make sure the web address <<URL>> is correct.
    ?Look for the page with your search engine.
    ?Refresh the page in a few minutes.

    I just checked with Chrome and Firefox. There following error appears: “This webpage has a redirect loop”

    Thread Starter stephanium

    (@stephanium)

    Problem solved.

    Thread Starter stephanium

    (@stephanium)

    I solved the problem with a workaround in search.php like you suggestet.
    I completely removed the search function in functions.php and my search.php looks like this now:

    <?php
    $my_query = new WP_Query();
    $my_query->get_posts();
    $searchterm = strtolower($_GET['s']);
    $i = 0;
    
    while($my_query->have_posts())
    {
    	$my_query->the_post();
    
    	$title = strtolower(get_the_title());
    	$content = strtolower(get_the_content());
    
    	if(strpos($title, $searchterm) || strpos($content, $searchterm))
    	{
    		if($i == 0)
    		{
    			print '<header class="page-header">';
    				print '<h1 class="page-title">'; printf( __( 'Suchergebnisse f&uuml;r: %s', 'twentytwelve' ), '<span>' . get_search_query() . '</span>' ); print '</h1>';
    			print '</header>';
    			twentytwelve_content_nav( 'nav-above' );
    		}
    		get_template_part( 'content', get_post_format() );
    		$i++;
    	}
    }
    if($i == 0)
    {?>
    	<article id="post-0" class="post no-results not-found">
    		<header class="entry-header">
    			<h1 class="entry-title"><?php _e( 'Keine Suchergebnisse', 'twentytwelve' ); ?></h1>
    		</header>
    
    		<div class="entry-content">
    			<p><?php _e( 'Bitte versuchen Sie es erneut mit anderen Schlagw&ouml;rtern.', 'twentytwelve' ); ?></p>
    			<?php get_search_form(); ?>
    		</div><!-- .entry-content -->
    	</article><!-- #post-0 -->
    <?php }
    else
    {
    	twentytwelve_content_nav( 'nav-below' );
    }
    ?>

    Thank you very much for your help, shariqkhan2012!

    Thread Starter stephanium

    (@stephanium)

    I didn’t get any results with the default search after an WP Update. After lots of Troubleshooting and researching I decided to just write an own function.
    I read, the parameter ‘s’ should execute a “normal” search through the Posts. So tried to get results with something like this:

    $args = array(
    	's' => $searchterm
    );
    query_posts($args);

    But when using the Parameter ‘s’ I always ended up with an HTTP Error 500

    I read that search.php is only there for displaying the results. But when that’s easier, I’ll try to modify the query directly in search.php

    Thread Starter stephanium

    (@stephanium)

    Because I had some problems with my search-engine (it never found any results) I wrote an complete new search-function:

    function searchFilter($query) {
    	if ($query->is_search)
    	{
    		query_posts();
    
    		$searchterm = strtolower($_GET['s']);
    		$include_posts = array();
    
    		if (have_posts())
    		{
    			while (have_posts())
    			{
    				the_post();
    
    				$title = strtolower(get_the_title());
    				$content = strtolower(get_the_content());
    
    				if(strpos($title, $searchterm) || strpos($content, $searchterm))
    				{
    					$include_posts[] = get_the_ID();
    				}
    			}
    		}
    
    		if(!empty($include_posts))
    		{
    			$args = array(
    				'post__in' => $include_posts,
    				'is_search' => true
    			);
    			wp_reset_query();
    			query_posts($args);
    
    		}
    		else
    		{
    			wp_reset_query();
    		}
    	}
    }
    add_filter('pre_get_posts', 'searchFilter');

    I first wanted to filter the posts with the parameter ‘s’ in $args. But when using that parameter I always ended up with an HTTP 500 Error.

    Thread Starter stephanium

    (@stephanium)

    In functions.php of my theme

    Thread Starter stephanium

    (@stephanium)

    I think im closer to the solution now…
    In the Themes function.php I placed following function:

    function searchFilter($query) {
    	if ($query->is_search)
    	{
    		wp_reset_query();
    		$args = array ( 's' => $_GET['s'] );
    		query_posts( $args );
    	}
    }
    add_filter('pre_get_posts', 'searchFilter');

    search.php should Display my results with following Code:

    <?php if ( have_posts() ) : ?>
    
    			<header class="page-header">
    				<h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'twentytwelve' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
    			</header>
    
    			<?php twentytwelve_content_nav( 'nav-above' ); ?>
    
    			<?php /* Start the Loop */ ?>
    			<?php while ( have_posts() ) : the_post(); ?>
    				<?php get_template_part( 'content', get_post_format() ); ?>
    			<?php endwhile; ?>
    
    			<?php twentytwelve_content_nav( 'nav-below' ); ?>
    
    		<?php else : ?>
    
    			<article id="post-0" class="post no-results not-found">
    				<header class="entry-header">
    					<h1 class="entry-title"><?php _e( 'Nothing Found', 'twentytwelve' ); ?></h1>
    				</header>
    
    				<div class="entry-content">
    					<p><?php _e( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.', 'twentytwelve' ); ?></p>
    					<?php get_search_form(); ?>
    				</div><!-- .entry-content -->
    			</article><!-- #post-0 -->
    
    		<?php endif; ?>

    When I search something now, I’m getting the Error “The website cannot display the page”… anybody got an idea, what’s wrong with my function? Or is there missing code in some other file, that everything can be displayed?

    If the question still is relevant…

    Open /plugins/post-by-email/class-post-by-email.php
    search for:
    wp_schedule_event( current_time( 'timestamp', 1 ) + HOUR_IN_SECONDS, 'hourly', 'post-by-email-wp-mail.php' );
    replace HOUR_IN_SECONDS with MINUTE_IN_SECONDS. If you do this it will reduce the time to 1min.
    If you want 5 Minutes or more between every check you could solve it with this code:
    wp_schedule_event( current_time( 'timestamp', 1 ) + (5 * MINUTE_IN_SECONDS), 'hourly', 'post-by-email-wp-mail.php' );

    Thread Starter stephanium

    (@stephanium)

    Sorry unterstood that wrong ??

    Thread Starter stephanium

    (@stephanium)

    I noticed, that this Problem is only showing up in the Internet Explorer. I enlarged the result box with the CSS. Now ist also showing up correct.

    Thread Starter stephanium

    (@stephanium)

    Sorry wrong Links to Pictures…
    On my Homepage
    wp-admin preview

    Thread Starter stephanium

    (@stephanium)

    –Topic resolved–

    Thread Starter stephanium

    (@stephanium)

    Sorry I’ve got the solution now!

    There was an wrong Setting in a Plugin witch I didn’t see

    Thread Starter stephanium

    (@stephanium)

    Thanks for the reply
    But it’s still not working with your code ??

    With your Code it doesn’t find something in the title or Content at all.

    Thread Starter stephanium

    (@stephanium)

    Found the Problem! ??

    Here’s the fix:
    – Open \wp-includes\query.php

    Search for this Function:

    $search_orderby = apply_filters( 'posts_search_orderby', $search_orderby, $this );
    if ( $search_orderby )
                $orderby = $orderby ? $search_orderby . ', ' . $orderby : $search_orderby;

    …and replace it with:

    $search_orderby = apply_filters( 'posts_search_orderby', $search_orderby, $this );
    if ( $search_orderby )
                $orderby = $orderby ;

    Also search for this Function:

    // Paging
    if ( empty($q['nopaging']) && !$this->is_singular ) {
                $page = absint($q['paged']);
                if ( !$page )
                            $page = 1;
                if ( empty($q['offset']) ) {
                            $pgstrt = absint( ( $page - 1 ) * $q['posts_per_page'] ) . ', ';
                } else { // we're ignoring $page and using 'offset'
                            $q['offset'] = absint($q['offset']);
                            $pgstrt = $q['offset'] . ', ';
                }
                $limits = 'LIMIT ' . $pgstrt . $q['posts_per_page'];
    }

    …and replace it with:

    // Paging
    if ( empty($q['nopaging']) && !$this->is_singular ) {
                $page = absint($q['paged']);
                if ( !$page )
                            $page = 1;
                            if ( empty($q['offset']) ) {
                            $pgstrt = ($page - 1) * $q['posts_per_page'] . ' ROWS FETCH NEXT ';
                } else { // we're ignoring $page and using 'offset'
                            $q['offset'] = absint($q['offset']);
                            $pgstrt = $q['offset'] . ' ROWS FETCH NEXT ';
                }
                $limits = 'OFFSET ' . $pgstrt . $q['posts_per_page'] . ' ROWS ONLY';
    }

    I didn’t write down the Link, where I found this Fix. But its working for me.

Viewing 15 replies - 1 through 15 (of 23 total)