Support » Theme: GridBulletin » search custom fields from external database

  • Resolved axelmktg

    (@axelmktg)


    Hi all,

    Love this theme! I would like to customize the search.php to make it retrieve results from another wordpress database (hosted on a local server).

    To my understanding, i can connect to any database with the following script

    $mydb = new wpdb('username','password','database','localhost');

    I am struggling to implement this code in the search.php

    <?php
    /*
     * The template for displaying search results.
     */
    ?>
    
    <?php get_header(); ?>
    
    <div id="content-full">
    <div class="article-full">
    
    	 <?php if ( have_posts() ) : ?>
    	 <h3 class="page-title"><?php printf( __( 'Search Results for: %s', 'gridbulletin' ), '<span>' . get_search_query() . '</span>' ); ?></h3>
    
    	<?php while ( have_posts() ) : the_post(); ?>
    
    	<?php if ( has_post_thumbnail() ) {
    		the_post_thumbnail();
    		} ?>
    
    	<div class="post-home<?php if( $wp_query->current_post%3 == 0 ) echo ' left'; elseif ( $wp_query->current_post%3 == 2 ) echo ' right'; ?>">
    
    <center><table>
    		<h5 class="post-title">
    				<a href="<?php the_field('buyurl'); ?>"><span style="color:black;">
    <?php if (strlen($post->post_title) > 35) {
    echo substr(the_title($before = '', $after = '', FALSE), 0, 60) . '...'; } else {
    the_title();
    } ?></span></a>
    				</h5>
    			<tr>
    				<td style="max-width:150px">
    	<center><br>
    	<?php
    		$thumb = get_post_meta($post->ID, 'picture', true);
    			if ($thumb == '')
    	{ ?>
    		<a href="<?php the_field('buyurl'); ?>">
    		<img src="/wp-content/images/noimage.jpg" width="125" height="125"></a>
    
    		<?php } else { ?><a href="<?php the_field('buyurl'); ?>">
    			<img src="<?php echo $thumb; ?>" width="125" height="125"></a>
    	<?php } ?>				</center>
    
    	<br>
    <h5><a href="<?php the_field('buyurl'); ?>">
    Price:<span style="color:green;"><b>$<?php the_field('price'); ?></b></span></a></h5><h6><a href="<?php the_field('buyurl'); ?>">Check Shipping Rate</a> </h6>
    <h6>Offered by <a href="<?php the_field('buyurl'); ?>"><?php the_field('programname'); ?></a></h6>
    <a href="<?php the_field('buyurl'); ?>" >Visit Store</a>
    <h6><a href="<?php the_permalink() ?>" >more info</a></h6>
    
    			</tr>
    	</table></center>
    	<br>
    </div>
    
    		<?php endwhile; else: ?>
    
    	<h3 class="page-title"><?php _e( 'Nothing Found', 'gridbulletin' ); ?></h3>
    		<p><?php _e('Sorry, no products are found.', 'gridbulletin'); ?></p>
    		<?php get_search_form(); ?>
    
    	<?php endif; ?>
    
    	<div class="post-nav">
    		<div class="nav-prev"><?php next_posts_link(__( '&laquo; More Products', 'gridbulletin' )) ?></div>
    		<div class="nav-next"><?php previous_posts_link(__( 'More Products &raquo;', 'gridbulletin' )) ?></div>
    	</div>
    
    </div>
    </div>
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Any help will be greatly appreciated!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Theme Author Guido

    (@guido07111975)

    Hi,

    Sorry I have no idea how to create a function like that and if that is possible or not. The whole search function is done by the cms WordPress itself and not by my theme.

    Guido

    Theme Author Guido

    (@guido07111975)

    Closed because of no replies.

    Guido

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘search custom fields from external database’ is closed to new replies.