Add/Modify rel=canonical of all the pages of a wordpress website

You’ll want to prevent SEO plugins from adding a canonical meta tag, and then add your own canonical meta tag using wp_head filter (untested): add_action( ‘wp_head’, static function () { $url = trailingslashit( get_site_url() ); $url .= ltrim( $_SERVER[‘REQUEST_URI’], “https://wordpress.stackexchange.com/” ); printf( ‘<link ref=”canonical” href=”%s” />’, esc_attr( $url ) ); } );

How can i add a script with parameters?

Use wp_enqueue_script from your PHP code to register and enqueue a script. WordPress will then handle automatically adding the required script tags at the right place and you’ll be able to instantiate and use the API from your javascript. E.g. (untested, check the docs for your use case) wp_enqueue_script(‘googlemaps’, ‘https://maps.googleapis.com/maps/api/js?&key=KEY’);

wordpress media library description column

Use the nl2br() function (tested): function column_id_row( $columnName, $media_item ) { if ( ‘description’ !== $columnName ) { return; } $attachment_meta = get_post( $media_item ); echo nl2br( $attachment_meta->post_content ); } add_filter( ‘manage_media_custom_column’, ‘column_id_row’, 10, 2 );

How to get default variation ID (woocommerce)

Try this code add_filter(‘woocommerce_variable_price_html’, ‘custom_variation_price’, 10, 2); function custom_variation_price( $price, $product ) { $available_variations = $product->get_available_variations(); $selectedPrice=””; $dump = ”; foreach ( $available_variations as $variation ) { // $dump = $dump . ‘<pre>’ . var_export($variation[‘attributes’], true) . ‘</pre>’; $isDefVariation=false; foreach($product->get_default_attributes() as $key=>$val){ // $dump = $dump . ‘<pre>’ . var_export($key, true) . ‘</pre>’; // $dump … Read more

Display data with a yes or no condition ACF

if ( get_field( “models-ad_fly” ) ): echo ‘<div class=”icon_plane”><i class=”icon-social_fly”></i></div>’; endif; or if you want to assign the output to a variable if ( get_field( “models-ad_fly” ) ): $output .= ‘<div class=”icon_plane”><i class=”icon-social_fly”></i></div>’; endif;

Restricting Image Upload Sizes using ‘wp_handle_upload_prefilter’ – Stuck media progress bar when Featured Image?

Try using JavaScript to handle this situation. The script should run when a user attempts to upload an image, and if the image upload fails, it will remove the associated UI elements (including that stubborn loading bar). Here’s a quick code: jQuery(document).ready(function($) { wp.Uploader.prototype.init = function() { this.uploader.bind(‘BeforeUpload’, function(uploader, file) { uploader.settings.multipart_params = { …uploader.settings.multipart_params, … Read more

How to pass variable from wp_loaded hook to custom function?

passing hook $_GET value from hook to function. The reason I’m using wp_loaded hook is because he is the only one that able to receive $_GET values. This is not a thing. Hooks don’t receive $_GET values, that’s not something that happens or needs to be done. You can use $_GET anywhere. You can safely … Read more