Sorting dynamic select/dropdown for Contact Form 7 of Modern Tribe Events posts

For any poor soul out there that stumbles on the same, niche problem, the answer was frustratingly simple. Instead of trying to reinvent the wheel and build my own query, I should’ve been using the tribe_get_events function that I’m sure the Modern Tribe devs already worked hard to write. Anyway, here’s the final solution for … Read more

Woocommerce Product_cat for current category page

Try to get category info using $category = get_queried_object(); $cpt_cat = $category->term_id; $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 10, ‘tax_query’ => array( array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘term_id’, ‘terms’ => $cpt_cat, ), ), ); // Custom query. $query = new WP_Query( $args ); if ( $query->have_posts() ) { global $wpdb; /* Start … Read more

get_page_template_slug returns incorrect path

I just checked what the function you called does and it just retrieves the _wp_page_template value from the wp_postmeta table of WordPress. So probably the structure of your theme is not right, some rewrites are active, or something else (e.g. plug-in) altered this database table. You could check that the theme root directory is indeed … Read more

if ( ! function_exists

The child theme functions.php is actually loaded first (this is intentional and desired behaviour.) So despite the function_exists check in your child theme, it will achieve nothing, as it seems the parent theme does not have this wrapper and is loaded second, so a fatal error occurs. There is no easy way to override a … Read more

Extract links from content

I thought regex search may become critical so html dom parser may help. See the code below (if it helps): <?php $post_content = get_the_content(); $dom = new DomDocument(); $dom->loadHTML($post_content); foreach ($dom->getElementsByTagName(‘a’) as $item) { echo “<a href=”https://wordpress.stackexchange.com/questions/315648/.$item->getAttribute(“href’).” target=”_blank” rel=””. $item->getAttribute(“rel’) .”‘>”. $item->getAttribute(‘title’) .”</a><br />”; } ?>

How to pass current loop data into nested loop

What you’ve done with the variable is correct (defining it before starting the next loop), but you’re not outputting it correctly: <p>current post = <?php $current_page; ?></p> If you want to output $current_page to the screen, you need to echo it: <p>current post = <?php echo $current_page; ?></p>

How to unserialize data from MySQL

As @Jacob said : To retrieve your option data : $your_data = get_option(‘option_tree’); To save your new data to the option : $new_data = array(…); update_option(‘option_tree’, $new_data);