houke / color-palette-generator

This WordPress plugin allows you to generate & show color palettes for all your images in your Media Library.
https://www.thearthunters.com/color-palette-generator-wordpress/
23 stars 6 forks source link

ACF Gallery #2

Open garethhorner opened 5 years ago

garethhorner commented 5 years ago

Hi I have a cpt set up titled 'works' and using an acf pro gallery-field titled 'rga_images' - im appending the main url with the various /color/color options but nothing is showing up. What's the best option here? Do I need to edit the search.php template?

Incredible work on the plugin btw

houke commented 5 years ago

I override the default search query if several params are set. (You can check https://github.com/houke/color-palette-generator/blob/master/inc/cpg-admin-search-rewrites.php#L26).

After the query is altered I check for a custom search template. If your theme already has a custom search template it might need to be changed. Else I fallback on the search template in the plugins folder: https://github.com/houke/color-palette-generator/blob/master/templates/search.php.

If you want to add your own search template for our plugin, add a templates folder to your theme and add search.php in there.

garethhorner commented 5 years ago

Hey Happy new year! Thank you for your reply - I've tried to understand but fear it is a bit beyond me, I have a custom search template implemented and working but still the plugin tells me 'No artworks found for this color...'

I understand and apologise for being a little naive here. I can view all my media and associated palettes are generated so the plugin is working. I just can't understand how to associate it with my custom post type 'works' when searching, any help would be massively appreciated now - and happy to make a donation to offer my thanks

Desperate to use this plugin as I think its fantastic!

houke commented 5 years ago

No worries :) Let's see if we can figure this out.

What is the result? Do you see the image? I've tested above scenario in a new website with only the color palette generator and I get the coffee image back as a result.

garethhorner commented 5 years ago

Hey - Followed the steps, and this is what I see http://ryanganderarchive.com/color/brown I can see the image on the backend with the generated palette with the same #82624a dominant colour So somewhere I’ve gone wrong right?

— Gareth Horner garethhorner.eu

On 8 January 2019 at 18:11:32, Houke (notifications@github.com) wrote:

No worries :) Let's see if we can figure this out.

What is the result? Do you see the image? I've tested above scenario in a new website with only the color palette generator and I get the coffee image back as a result.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/houke/color-palette-generator/issues/2#issuecomment-452397034, or mute the thread https://github.com/notifications/unsubscribe-auth/AKJRv85UGu46p4ABaoOO_UzTCDzrvm1sks5vBN9NgaJpZM4ZHKYU .

houke commented 5 years ago

How are your permalinks set? (Settings > Permalinks). Try to set that one on Post Name if it isn't already.

Does that change anything?

Do you have other plugins active as well?

garethhorner commented 5 years ago

Yeah permalinks are set as you mentioned :(

screenshot 2019-01-09 at 09 20 38 screenshot 2019-01-09 at 09 20 48

Notable plugins in use… ACF Pro 5 CPT UI SearchWP

Some more info…

` WordPress Version: 5.0.2 Permalink Structure: /%postname%/ Active Theme: Ryan Gander Archive 0.6

    Registered Post Types:    post, page, attachment, revision, nav_menu_item, custom_css, customize_changeset, oembed_cache, user_request, wp_block, acf-field-group, acf-field, works

    PHP Version:              7.0.33
    MySQL Version:            5.6.41
    Web Server Info:          Apache

    Show On Front:            page
    Page On Front:            Front Page (#23)
    Page For Posts:            (#0)`
garethhorner commented 5 years ago

It's not because I'm on Wordpress 5 is it?

houke commented 5 years ago

WP5 isn't the issue, I am using it with no problem with 5.0.2. I see you've SearchWP as a plugin. I think they alter the search query as well and we might collide with one another.

What happens if you disable that one for a bit?

garethhorner commented 5 years ago

Yeah turning off SearchWP has worked! — http://ryanganderarchive.com/color/grey

houke commented 5 years ago

Good to hear :). I think we're both modifying the search query and SearchWP was overwriting mine. It's a paid plugin from the looks of it, so I won't be able to debug further I think.

Are you planning to use SearchWP in the future?

garethhorner commented 5 years ago

Spoke too soon, deleted the previous comment. CPG is working with https://wordpress.org/plugins/acf-better-search/ installed rather than SearchWP, amazing.

Do have one more query - now that I can see the plugin working, is it possible to show the post an attachment is related too rather than a list of the attachments like so… http://ryanganderarchive.com/color/grey

Essentially displaying like the search template here… http://ryanganderarchive.com/search/art

Does it require customising the search template in the CPG plugin folder?

houke commented 5 years ago

I think there is already a custom search template active. My template would output this by default

                if ( have_posts() ) {
                    while ( have_posts() ) {
                        the_post();
                        $cpg_img = wp_get_attachment_image_src( get_the_ID(), 'thumbnail' );
                        $cpg_link = get_permalink( get_the_ID() );
            ?>
                <div class="c-search__result">
                    <a href="<?php echo $cpg_link; ?>">
                        <img src="<?php echo $cpg_img[0]; ?>" alt="<?php echo get_the_title(); ?>" />
                        <span><?php echo get_the_title(); ?></span>
                    </a>
                </div>
            <?php
                    }
                    echo get_the_posts_pagination();
                } else {
                    echo '<h2>No artworks found for this color...</h2>';
                }

So the first step for you would be to find the template in your theme which is setting the layout you're seeing