Add itemprop Schema.org Markup to li Elements in wp_nav_menu

To add attributes to the menu’s li elements, you’d have to write your own custom walker that extends the default Walker_Nav_Menu class (which is itself an extension of the Walker class). For more info: https://codex.wordpress.org/Class_Reference/Walker But as itemprop=”url” should normally be added to anchor elements, you could use the nav_menu_link_attributes filter. For example, as per … Read more

Converting html to wordpress images not showing

In your comments you mentioned that you are still new to wordpress, and I believe you don’t have a full understanding of the template hierarchy. Essentially, wordpress looks for certain templates depending on what post type is being displayed. And if it can’t find any, the last resort is always the index.php file. Here is … Read more

How to rename “Publish” metabox title in post screen

The best way would be to remove the meta box and then add it back in with your new title: function change_publish_meta_box() { remove_meta_box( ‘submitdiv’, ‘post’, ‘side’ ); add_meta_box( ‘submitdiv’, ‘YOUR TITLE HERE’, ‘post_submit_meta_box’, null, ‘side’, ‘high’ ); } add_action( ‘add_meta_boxes_post’, ‘change_publish_meta_box’ ); (Change YOUR TITLE HERE to whatever you want)

Limiting woocommerce line_total decimal length

Just round the decimal to two digit as per your requirement. $myID = 2859; $myorder = new WC_Order($myID); foreach ($myorder->get_items(‘line_item’) as $item) { $rounded_total = round($item[“line_total”],2);// allow 2 decimal and avoid further $Data = $Data.OrderLine($item[“name”], $rounded_total, $item[“line_tax”], $item[“qty”], “piece”, “x”); }

wp_dropdown_categories and custom attribute

The only filter available is wp_dropdown_cats, which allows you to filter the entire HTML select string and that means trying to string-match markup. That is always a bit questionable. Still… function dropdown_data_attr_wpse_213033($output){ return str_replace(‘<select’,'<select data-live-search=”true”‘,$output); } add_filter(‘wp_dropdown_cats’,’dropdown_data_attr_wpse_213033′); wp_dropdown_categories(); // test

PHP code inside shortcodes

You can not put PHP functions inside your shortcode. However, you do not need to. You can just use your foreach-loop to create the html and store it in a variable, for example $shortcodehtml. So, afterwards, you can call echo do_shortcode(‘[O_U user_name=”operator” blocked_message=”This page is restricted for guests.”]’ . $shortcodehtml . ‘[/O_U]’); The better version … Read more

Multiple Loops Inside a Function

the permalink and post title won’t be available until after you’ve run the query. the following should return the last 3 posts from the designated category. the same post is being displayed 3 times because it doesn’t look like you’re setting the permalink or post title from within “the loop” if (!function_exists(‘get_posts_menus’)): function get_posts_menus($category_name, $count) … Read more