I am using WooCommerce and a plugin called WooCommerce Store PDF Catalog.
In the frontend.php file, there is 2 actions. 1 is to create a downloadable pdf button on the category pages and downloadable pdf on the single product pages.
I want to remove the action on the single product pages and only apply it to a specific category single page.
So for example, I have 5 categories but I only want to apply that button to category #3.
This is what the code looks like
public function display_button_on_single() {
global $wp_query;
$post_ids = array();
// gather all ids
foreach( $wp_query->posts as $post ) {
$post_ids[] = $post->ID;
}
$output = '';
$output .= '<p class="wc-store-catalog-pdf-download">' . PHP_EOL;
$output .= '<a href="#" class="wc-store-catalog-pdf-download-link button" target="_blank" download=""><i class="icon-file-pdf" aria-hidden="true"></i> ' . $this->link_label . '</a>' . PHP_EOL;
$output .= '<input type="hidden" value="true" name="is_single" />' . PHP_EOL;
$output .= '<input type="hidden" value="' . esc_attr( json_encode( $post_ids ) ) . '" name="posts" />' . PHP_EOL;
$output .= '</p>' . PHP_EOL;
echo $output;
}
The button gets generated in the woocommerce_single_product_summary hook.