wp_nonce_field is breaking form for reasons unknown

wp_nonce_field() will echo its output by default, so set the $echo parameter to false: add_shortcode(‘signup_form’, ‘get_signup_form’); function get_signup_form() { $wp_nonce_code = wp_nonce_field( -1, ‘_wpnonce’, true, false ); $signup_form_code = <<<EOT <form method=”post” class=”popup-register” action=”/my-account/”> <p style=”text-align:center;”> <input type=”email” class=”popup-input” style=”width: 65%;” name=”email” id=”reg_email” placeholder=”Enter your email address”> <input type=”submit” class=”popup-input-submit button” style=”margin: 0; border: 1px … Read more

Function extending with if query in functions.php

may be it’s clearer like this : add_filter(‘wpseo_set_title’, function ($title) { if (is_single()) { $page_comment = get_query_var(‘cpage’); if ($page_comment > 3) { $title = “Kontroverse Diskussionen zu: $page_comment $title”; } elseif ($page_comment > 0) { $title = “Meinungen zu: $page_comment $title”; } } return $title; });

Auto Generated HTML source code formatting

I know it’s really trivial Yes. Yes it is. …we are shooting to do the best job possible Spending any time whatsoever on fixing tab indentation in your output HTML as opposed to focusing on the quality of your source code is not doing “the best job possible”. You should be minifying your HTML on-the-fly … Read more

Exclude category from shortcode

I don’t know of a direct method to achieve this, you should be able to get the category count using get_term then subtract that from the total. function product_count_shortcode( $atts ) { $data = shortcode_atts( array( ‘cat_id’ => 144, ‘taxonomy’ => ‘category’ ), $atts ); $category = get_term( $data[‘cat_id’], $data[‘taxonomy’] ); $count = $category->count; $count_posts … Read more

Function coding error concatenating quotes I think

If you’re evaluating php variables in a string(interpolating the variables directly in a string), it’s best to use double quotes, this way you don’t have to concatenante with dots. function get_highest_bid( ) { global $wpdb; $postid = get_post_id(); $table = $wpdb->prefix . “jwp_bids”; $highest_bid = $wpdb->get_var( “Select max(bid_amt) FROM $table WHERE post_id =’$postid’;” ); echo … Read more

Publishing just a Facebook URL without full code snippet

Note that Facebook is a registered oEmbed provider in the WordPress core. You could e.g. use the pre_oembed_result filter, before the HTTP request is made, to cancel it and override it to your needs. Here’s an example for Facebook posts: add_filter( ‘pre_oembed_result’, function ( $result, $url, $args ) { // override the HTML result for … Read more

(Woocommerce) Order by price when entering specific category

You can use the filter below, as suggested by @sabarnix at https://stackoverflow.com/questions/24939337/woocommerce-different-default-sorting-for-different-categories add_filter(‘woocommerce_get_catalog_ordering_args’, ‘tk_woocommerce_catalog_orderby’); function tk_woocommerce_catalog_orderby( $args ) { if( is_product_category( ‘shirts’ ) ) { $args[‘orderby’] = ‘meta_value_num’; $args[‘order’] = ‘ASC’; $args[‘meta_key’] = ‘_price’; } return $args; }