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

How to create an ACF shortcode with Repeater Field in WordPress? [duplicate]

you need to return your code when using shortcodes. Additionally you didn’t close the function. try this: function menu_loop() { $menu = ‘<div class=”entry-content dishes”>’; // check if the repeater field has rows of data if (have_rows(‘menu_sections’)): // loop through the rows of data while (have_rows(‘menu_sections’)) : the_row(); // display a sub field value $menu … Read more

Why does this update_post_meta function not delete the custom field itself?

You’re looking for delete_post_meta($post_id, $meta_key, $meta_value); Parameters $post_id (integer) (required) The ID of the post from which you will delete a field. Default: None $meta_key (string) (required) The key of the field you will delete. Default: None $meta_value (mixed) (optional) The value of the field you will delete. This is used to differentiate between several … 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

Filtering a function’ output for a new continued function

How about using a standard for loop instead: $sunnytags = get_tags ($tagargs); $count = count ($sunnytags); for ($i = 0; $i < ($count < 15 ? $count : 15); $i++) { $string .= ‘<a class=”tag2″ href=”‘. get_tag_link ($sunnytags[$i]->term_id) .'”>’. $sunnytags[$i]->name . ‘</a>’; } And then later, whether you re-run the query or (better still) save … 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