Adding `post_author` in php

Try this <div class=”my_edit_button”> <?php if ( $post->post_author == $current_user->ID ) { echo do_shortcode(‘[something]’); }?> </div>

How passing values ​​to construct function with Actions?

<?php class someClass { public function __construct($options = null, $initialize = true, $error_messages = null, $path, $qnty) { //construct what you see fit here…. } //etc.. } // Action listener add_action( ‘action_name’, create_function(”, “new someClass(implode(‘,’,func_get_args()));”), 10, 5 // IMPORTANT, number of arguments your construct function accept ); // Call the action $options = “options”; $initialize … Read more

Adding PHP in the menu

Add to your functions file and use wp_nav_menu_items add_filter(‘wp_nav_menu_items’,’wpsites_add_avatar_to_nav’, 10, 2); function wpsites_add_avatar_to_nav( $items, $args ) { if( $args->theme_location == ‘primary’ ) return $items; $dude = get_avatar( get_current_user_id(), 48 ); if (is_user_logged_in()) : echo'<li class=”your-custom-class right”>’ . $dude . ‘</li>’; endif; return $items; } Might need to use output buffering. Some work is required on … Read more

What does this mean in wordpress? Easy question

It’s the text domain, used for translation. When you run something like this: <?php _e( ‘Hello World’, ‘html5blank’ ) ?> …WordPress will attempt to find the translated string in the loaded MO file for HTML5 Blank: load_theme_textdomain( ‘html5blank’, ‘path/to/language.mo’ );

how to echo meta tag in header using php

Use the_title_attribute() to print the attribute. A post title might contain HTML, so you need the escaped content that this function returns. Also suppress immediate print-out, because that will set the output in front of the echo statement. if ( is_singular( ‘communications’ ) ) { $title = the_title_attribute( [ ‘echo’ => FALSE ] ); echo … Read more

Woocommerce change prices for a certain country [closed]

You need to use the woocommerce_get_price filter: add_filter(‘woocommerce_get_price’, ‘return_custom_price’, $product, 2); function return_custom_price($price, $product) { global $post, $woocommerce; // Array containing country codes $county = array(‘CH’); // Amount to increase by $amount = 5; // If the custromers shipping country is in the array if ( in_array( $woocommerce->customer->get_shipping_country(), $county ) ){ // Return the price … Read more