Use of undefined constant issue

It’s possible that your $http_host isn’t in the list of possible choices. You can always check first that the ENVIRONMENT constant has actually been defined: if ( defined( ‘ENVIRONMENT’ ) && ‘local’ === ENVIRONMENT ) { define(‘ASSETSDIR’, get_template_directory_uri() . ‘/assets’); } else { define(‘ASSETSDIR’, $dist_dir . ‘/assets’); }

Error with PHP 8

You are using a global variable called $post in your code, but this variable is not defined. To fix this issue, you can try defining the $post variable at the top of your script: <?php global $post; if (get_the_terms($post->ID, ‘ausstattung’)) { $taxonomy_ar = get_the_terms($post->ID, ‘ausstattung’); echo “”; $output=”<ul>”; foreach ($taxonomy_ar as $taxonomy_term) { $output .= … Read more

How to group by column a and sum column b and c in a php array

To group and sum the values in your array by the shipping field, you can use a loop and a temporary associative array to store the intermediate results. Here is an example of how you can do this: $result = array(); foreach ($array as $item) { $shipping = $item[‘shipping’]; if (!isset($result[$shipping])) { $result[$shipping] = array( … Read more

Count custom posts type and filter by tag

wp_count_posts is not affect your custom query. You can use found_posts to return the number of posts from the custom query. So try to change the code after your loop query as follows. Hope it helps. if ($loop->have_posts()) : $count_posts = $loop->found_posts; echo “<p>Total: $count_posts cars</p>”; else : echo “<p>No cars available.</p>”; endif; wp_reset_query();

I have an error WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version

The problem here you are passing table name as a placeholder in prepare statement. Which is not allowed. You can directly add the table name in your query without quotes. Your query do not have any placeholder and arguments. So No need for prepare statement. Try following code. global $wpdb; $vragen = $wpdb->get_results( “SELECT * … Read more

How call WordPress shortcode inside function file

I need echo do_shortcode(‘[Shortcode]’); to go where it says “New Item Contents here!” is there any way to do this? Just put it there: add_action( ‘woocommerce_account_new-item_endpoint’, ‘add_new_item_content’ ); /** * Add content to the new tab. * * @return string. */ function add_new_item_content() { echo do_shortcode(‘[Shortcode]’); } Maybe I’m misunderstanding the question, but that’s all … Read more