How do I query a single data value from the wp_metadata table?

You need to use get_post_meta: get_post_meta( $post_id, $key = ”, $single = false ) Retrieve post meta field for a post $post_id (int) (Required) Post ID. $key (string) (Optional) The meta key to retrieve. By default, returns data for all keys. Default value: ” $single (bool) (Optional) Whether to return a single value. Default value: … Read more

Website completely messes up when logging out

If you check out the browser’s console, you can see that several stylesheets are not loading. Also, there’s this error: Resource interpreted as Stylesheet but transferred with MIME type text/html: “https://www.counterboosting.com/wp-content/cache/minify/000000/M9BPLCjIz8wryU3NK9EvLqnMSQUA.css“. It appears that you have a plugin installed that does caching/script minification, and something is not configured correctly there. The plugin is probably configured … Read more

Adding php script to WordPress [closed]

This is a crude PHP Script, you will need first to have notions about WordPress hooks to implement it for example in a Plugin. Please learn about these topics. Well, in response to your comment, that depends on the workflow of your project/website, to know exactly at what point fire the code. This is an … Read more

How to remove the space before the ellipsis in excerpt?

WordPress adds a space when applying the excerpt_more filters. Filter the excerpt_more to change this correctly. https://codex.wordpress.org/Plugin_API/Filter_Reference/excerpt_more add_filter(‘excerpt_more’, ‘theme_name_filter_excerpt_more’); function theme_name_filter_excerpt_more() { return ‘…’; }

Overide Variable in Child Theme

To override the variable directly add the fucntion print_page_title in child theme functions.php this should work as the parent theme uses if(!function_exists(‘print_page_title’)) condition to check for the function, since child theme’s function.php is loaded first this is used instead of parent theme. Place the following code in your child-theme’s functions.php function print_page_title() { global $post; … Read more

How to add post classes?

function imageHolder($id){ $category = get_the_category($id); $class=””category-” . strtolower($category[0]->cat_name) . ‘”‘; print <<<HTML <div class=$class> This is a Test </div> HTML; } imageHolder(‘1′); Please be careful about using ‘/n’ or ‘/r’ symbol in the Heredoc syntax(they might cause the function does not work properly).

How to tag the main tag? [closed]

You can’t make a main tag per post. Tags are a not hyerarchycal taxonomy, and by definition, not hyerarchycal taxonomies have no hyerarchy, none of the terms can be more important than each other. In order to accomplish your task, most WP developers would suggest yo to make some custom field to store your “main … Read more

array_rand not working correctly?

Getting a single random post would be far more efficient than getting all posts, then plucking a random post from the query. Here’s an updated WP_Query instance using ‘orderby’ => rand: $args = array( ‘orderby’ => ‘rand’, ‘posts_per_page’ => ‘1’, ‘paged’ => $paged, ‘post_type’ => ‘Didyouknows’, // Post type names should never use capital letters, … Read more

Get all posts from categories

From the it looks like you want to get all products grouped by category. Your query seems to be correct except $term_slug need not be in quotes. $tax_post_args = array( ‘post_type’ => ‘bpo_microsoftoffice’, ‘posts_per_page’ => 999, ‘order’ => ‘ASC’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘bpo_microsoftoffice_reg’, ‘field’ => ‘slug’, ‘terms’ => $term_slug ) ) ); … Read more