-
AuthorPosts
-
September 23, 2013 at 11:35 pm #288
Do you know how I can display 100 images in the results page of the search engine of my site? Now with the default configuration I see only 24 images.
Thanks a lot!September 24, 2013 at 12:42 am #3117Right now, you would need to edit functions.php to do this. I think it should be a UI option in the WordPress dashboard, but I did make the edit on my own site to change the default from 24 to 48 – that works for Category browsing or search results from your site (network search results use a different parameter.
It’s better to use a multiple of 6 given how the pages are laid out – at least for clean theme.
Here is the change:
//set the results per page depending on if we are doing image search
function symbiostock_image_results_per_page( $query ) {
$network_search = get_query_var(‘symbiostock_network_search’);if($network_search != true && !is_admin()){
$marketer_user_key = get_option(‘marketer_user_number’);
$marketer_key = get_query_var( ‘ss-‘ . $marketer_user_key );// jas – original per_page was 24; multiples of 6 work best
// jas begin
isset($marketer_key ) && !empty($marketer_key) ? $per_page = 100 : $per_page = 48;
// jas end
$query->set(‘posts_per_page’, $per_page);
return;
}
}
September 24, 2013 at 11:27 am #3118Thanks jsnover!!
Works all fine 🙂September 24, 2013 at 2:58 pm #3119Any idea of how to do it with the default child theme?
September 24, 2013 at 3:18 pm #3120The change I made is to functions.php in the parent theme.
You can make a functions.php in the default child theme and put just that one function into it if you prefer to edit things that way, but be aware that if the parent theme’s version of that function changes in the future, your older (based on the prior version) function will be used. That may or may not be OK depending on what else has changed.
This sort of thing needs to be a parameter pulled from the UI, not code in either the parent or child theme, but I just offered this as a quick fix.
Do keep a copy somewhere other than on the site of what you’ve edited so you can re-apply the changes after an update (assuming the change is still needed)
September 24, 2013 at 4:04 pm #3121The Symbiostock child does have a functions.php file already. I pasted the above code into it but nothing changed.
September 24, 2013 at 4:31 pm #3122This is a link to a Code Editor that Leo created exactly for adding code for more images – I wonder if it could be used for more things?
http://kerioakimaging.com - trying to reopen
http://nail-art-at.kerioak.com - Art and Nail ArtSeptember 24, 2013 at 4:32 pm #3123@donland wrote:
The Symbiostock child does have a functions.php file already. I pasted the above code into it but nothing changed.
You have to paste the whole function, not a snippet from the middle of one.
September 24, 2013 at 4:39 pm #3124@christine wrote:
This is a link to a Code Editor that Leo created exactly for adding code for more images – I wonder if it could be used for more things?
And is there a “code snippet archive” somewhere?
I don’t think changing the number of images per page of results should require code at all – it’s a parameter that right now is a magic number hardcoded in a PHP file and it needs to be pulled from the UI instead (with possibly some simple limits and a default of 24).
Without seeing the code for this plugin I can’t really say, but it sounds as if it’s an editor for functions.php somewhat like Jetpack’s Edit CSS for style.css. There was no mention of the user saying which PHP file the code snippet was to be injected into.
And for many of the items I’ve done kludgey changes for, you couldn’t change those behaviors by stuffing a code snippet elsewhere – it would have to modify the function in the PHP file that currently implements the behavior someone wants to alter.
September 24, 2013 at 5:22 pm #3125I did. I pasted everything from under but not including “Here is the change:”
I pasted it below all of the following:
< ?php
//write your functions below, they will be added to Symbiostock’s functionality
//more on child theme function writing here: http://codex.wordpress.org/Child_Themes?>
September 24, 2013 at 5:37 pm #3126You need to have your code within the php tags – after the comment and before the ?>
September 24, 2013 at 5:54 pm #3127Thank you. That is why I posted where I put it because I thought I may have made a mistake as I am not familiar with coding.
September 24, 2013 at 6:21 pm #3128Thanks but I keep getting an error when the code is within:
Fatal error: Cannot redeclare symbiostock_image_results_per_page() (previously declared in /home
I’ve tried removing the entire child theme and reinstalling it. I used a text editor to drop it in as well as the editor within WP.
September 24, 2013 at 6:26 pm #3129Just a note for anyone using the batch editor. I am getting a strange error message if I go to the Settings & Pricing section when the change I made here is in functions.php.
It makes no sense to me, but while I investigate, should you encounter the batch error message “This option not available with this host.”, just go back to the original (unedited) functions.php
-
AuthorPosts
You must be logged in to reply to this topic.