Woocommerce target first product thumbnail in loop to load a larger image
Woocommerce target first product thumbnail in loop to load a larger image
Woocommerce target first product thumbnail in loop to load a larger image
Welcome to WPSE and developing for WordPress! Many times functionality is placed in custom plugins, so that if you change your theme, the functionality remains. However, if you already have everything built in a custom theme, you may wish to include the code in that theme so that everything is in the same place. If … Read more
Updating from multiple array custom table
There were a couple security issues and error checking that I did see. Try these: <?php add_action(‘wp_ajax_get_timeslot_data’, ‘get_timeslot_data’); add_action(‘wp_ajax_nopriv_get_timeslot_data’, ‘get_timeslot_data’); function get_timeslot_data() { if (!isset($_POST[‘activityId’]) || !ctype_digit($_POST[‘activityId’])) { wp_send_json_error(“Invalid activity ID”); } global $wpdb; $activity_id = intval($_POST[‘activityId’]); $table_name = $wpdb->prefix . ‘booking_seasons’; // Support custom table prefixes $result = $wpdb->get_row($wpdb->prepare(“SELECT timeslot_dates FROM $table_name WHERE id … Read more
Relatively easy to achieve, just put this somewhere in your template within The Loop: <a href=”https://www.deparelevenementenservice.nl/<?php echo $post->post_name; ?>”>Link text</a>
WP stores URLs in a lot of different tables. You can either use a WP CLI command to search and replace the old URL to your new local URL, or use a plugin to do the same thing. Don’t just go do a blanket search-and-replace in phpMyAdmin or similar because the URLs are stored in … Read more
After posting the same question to multiple AI chatbots, CoPilot finally gave me an answer that works for both: add_action( ‘pre_get_posts’, ‘filter_files_admin_columns’ ); function filter_files_admin_columns( $query ) { if ( !is_admin() || ‘eri-files’ !== $query->get( ‘post_type’ ) ) { return; } add_filter( ‘posts_search’, ‘custom_search_query’, 10, 2 ); function custom_search_query( $search, $wp_query ) { global $wpdb; … Read more
You could build an intermediary array for the tax_query parameter: $tax_query = array(); $taxonomies = array( ‘product_cat’, ‘sub_category’, ); foreach ( $taxonomies as $taxonomy ) { if ( ! empty( $_POST[ $taxonomy ] ) ) { $tax_query[] = array( ‘taxonomy’ => $taxonomy, ‘terms’ => $_POST[ $taxonomy ], ); } } query_posts( array( // … ‘tax_query’ … Read more
As the warnings say, $post is used but not defined, hence “Undefined variable $post” and then ‘Attempt to read property “ID” on null’. It seems like the global $post is in an erroneous location and should be before the if statement: global $post; if ( is_singular() && wp_attachment_is_image ( $post->ID ) ) You may also … Read more
The WP_Query class does not generate HTML markup. WP_Query will query the WordPress content, and provide some data back. So using WP_Query and the sprintf() PHP function, the HTML markup can be generated (untested): $args = array( … ); $query = new WP_Query( $args ); $html=””; while ( $query->have_posts() ) { $query->the_post(); $saved_html .= sprintf( … Read more