Could you switch it to a global attribute created at Products > Attributes and then use that instead of a custom attribute? Then you can use the layered nav widget for filtering / querying.
Otherwise, this will require some custom code.
Yes, sure, but I want to keep this separate from variations, which I might use later. and I have most of the code I need… I just need the query array to work correctly. I’ve tried several options, but none seem to work.
[ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]
function ow_url_func() {
$args = array (
'post_type' => 'product',
'posts_per_page' => -1,
'meta_query' => array(
'course-name' => 'open-water-diver',
'compare' => 'like'
),
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) :
while ( $query->have_posts() ) : $query->the_post();
return '<a href="' . get_permalink() . '">' . get_the_title() . '</a>';
endwhile;
endif;
}
add_shortcode( 'owurl', 'ow_url_func' );
A custom attribute is stored as postmeta under the key of _product_attributes. However, the name and terms are in a serialized array so this will be a bit more complicated than your query above.
I can’t really help with custom coded solutions here though, so you may need to hire a developer if you can’t quite figure out the code you need:
– http://jobs.wordpress.net/
– https://codeable.io/
– https://woocommerce.com/experts/?project-scope%5B0%5D=1819