Adding Search to NextGEN-Gallery
Hi All,
I've found the following instructions to activate searching of tagged images in NextGEN-Gallery but I can't find the PHP file they refer to: 1) Add this code in your file search.php (inside your template folder), right after <h2 class="pagetitle">Search Results</h2> or somewhere (depending your template) after <?php if (have_posts()) : ?>, otherwise it wouldn’t find the pictures. Pay a special attention to the line $nggpictures = ngg_get_search_pictures($keywords, ''); since on the second function argument ( ” ) you may indicate the number of pictures you want to display on each row result. IE, if you want to get 6 pictures displayed on each row, you have to change the line to $nggpictures = ngg_get_search_pictures($keywords, '6'); By default, 4 pictures for each row are displayed. Note that you may also split the code, and put a part before and another part after the <?php while [...] ?> function with the result to display pictures (if relevent) even if there is no post. That’s a bit more advanced, but people with advanced php skills won’t need any complementary explanation to achieve that. 2) Add this code (or this code if you use NexGen 1.0) anywhere in your file functions.php (inside your template folder, create one if you don’t have any) The code for step on is Code:
if(is_search()) { The code for step 2 is: Code:
## Function to do searchs on gallery pics from NextGen Gallery plugin Cheers, Drew |
*Bump* Anyone?
|
Make a copy of index.php as search.php and put the code there.
Wrap both pieces of code into opening and closing php tags <?php ... ?> For the 2nd code, for functions.php, make sure you don't create blank lines anywhere outside of opening and closing PHP tags, anywhere in functions.php |
I have been fighting with this for days now and not getting any image results back. I think I found a fix. I have adjusted it below. The important part is the $wpdb->prefix statement. Combined with the information from Flynn, I got everything working, finally!
Code:
FROM " .$wpdb->prefix. "ngg_pictures Code:
/** |
Hey I just got a syntax error when I entered your new edited code below. What am I doing wrong? I added the stuff you said, in the search.php then in functions.php I just copy and pasted the last box of coding you've posted. So what do I do?
|
Maybe someone could post a sample search.php ?
And i don't understand how to put the search.php on the Menu on my page. Or should I make a New Page in Wordpress, called Search and copy the content of the index.php and the code in it? |
[quote=Flynn;6611]Make a copy of index.php as search.php and put the code there.
Wrap both pieces of code into opening and closing php tags <?php ... ?> Soooooooooo That would be like this?.............? <?php /** * Front to the WordPress application. This file doesn't do anything, but loads * wp-blog-header.php which does and tells WordPress to load the theme. * * @package WordPress */ /** * Tells WordPress to load the WordPress theme and output it. * * @var bool */ define('WP_USE_THEMES', true); /** Loads the WordPress Environment and Template */ require('./wp-blog-header.php'); ?><?php if(is_search()) { $search = $wp_query->get('s'); $keywords = preg_replace('/\+/',' ',$search); if (function_exists ('ngg_get_search_pictures')) { // function from functions.php $nggpictures = ngg_get_search_pictures($keywords, ''); // put the number of pictures by row you want, if you don't want "4" if ($nggpictures) { echo "<h2>Pictures</h2>"; echo $nggpictures; } } } php?> For the 2nd code, for functions.php, make sure you don't create blank lines anywhere outside of opening and closing PHP tags, anywhere in functions.php Where Exactly should I put this in the code?[/QUOTE] [quote=digimarc;8160]I have been fighting with this for days now and not getting any image results back. I think I found a fix. I have adjusted it below. The important part is the $wpdb->prefix statement. Combined with the information from Flynn, I got everything working, finally! QUOTE] If you understand my problem written above here.. then please explain me how you did manage to get it working. Thanks, Cerafil |
Will you be adding a search capability to the new update. ... like the search fonction of wordpress search into NextGen Gallery pictures too.............
|
Sorry for the necro post but im working on adding this as well. Does anyone know where he meant the
Code:
FROM " .$wpdb->prefix. "ngg_pictures |
So i got it working just so everyone knows and i wanted to add some small tid bits to help others having this problem.
1) Go to the atahualpa theme folder and copy index.php and rename it to search.php 2) In search.php Find: Code:
<?php /* If there are any posts: */ Code:
<?php if(is_search()) { 4) In Functions.php Find: Code:
<?php Code:
<?php /** |
The latest version of NextGen has support for XML sitemaps if you use Yoast's SEO plugin.
|
All times are GMT -6. The time now is 11:03 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.