$search_query, 'has_password' => false, 'post_type' => 'download', 'post_status' => 'publish', 'posts_per_page' => $max_results, 'no_found_rows' => true, ) ); if ( $wp_query->have_posts() ) { break; } } if ( ! $wp_query->have_posts() ) { return ''; } $lines = array( 'Digital downloads relevant to the query:' ); foreach ( $wp_query->posts as $post ) { $title = get_the_title( $post ); $url = esc_url( get_permalink( $post ) ); $price = edd_get_download_price( $post->ID ); if ( function_exists( 'edd_has_variable_prices' ) && edd_has_variable_prices( $post->ID ) ) { $price_text = 'Variable pricing; see product page'; } elseif ( function_exists( 'edd_is_free_download' ) && edd_is_free_download( $post->ID ) ) { $price_text = 'Free'; } elseif ( false !== $price ) { $price_text = function_exists( 'edd_currency_filter' ) ? wp_strip_all_tags( edd_currency_filter( edd_format_amount( $price ) ) ) : (string) $price; } else { $price_text = 'Variable pricing'; } $short_desc = wp_strip_all_tags( get_the_excerpt( $post ) ); $short_desc = '' !== $short_desc ? wp_trim_words( $short_desc, 25, '…' ) : ''; $line = "- {$title} | Price: {$price_text}"; if ( '' !== $short_desc ) { $line .= " | {$short_desc}"; } $line .= " | {$url}"; $lines[] = $line; } wp_reset_postdata(); if ( count( $lines ) <= 1 ) { return ''; } return implode( "\n", $lines ) . "\n"; }