Rename file after title , one small problem

Use get_the_title() since you’re already being passed a post ID. function rename_attacment( $post_ID ) { $post = get_post( $post_ID ); $file = get_attached_file( $post_ID ); $path = pathinfo( $file ); //dirname = File Path //basename = Filename.Extension //extension = Extension //filename = Filename $newfilename = get_the_title( $post_ID ); $newfile = $path[‘dirname’] . “https://wordpress.stackexchange.com/” . $newfilename … Read more

Why functions metaboxes is causing White Screen in Admin [closed]

Finally I found the solution in codex…. Interpreting the Error Message: If the error message states: Warning: Cannot modify header information – headers already sent by (output started at /path/blog/wp-config.php:34) in /path/blog/wp-login.php on line 42, then the problem is at line #34 of wp-config.php, not line #42 of wp-login.php. In this scenario, line #42 of … Read more

How do grab the main loop, with conditions, and output via shortcodes

Are you sure you want to do this in this manner? Normally a section like this might be written to the page template somehow and not called via the content editor. That being said, this should do what you need: add_shortcode( ‘show_xyz_news’, ‘xyz_news_query’ ); function xyz_news_query() { $args = array( ‘posts_per_page’ => 3, ‘category_name’ => … Read more

Trying to get this function to show below the content

If it was me I’d not echo the text I’d make it a variable e.g. $additional_text = “” then at the end of the function return $additional_text;. if (have_posts()) : while (have_posts()) : the_post(); $additional_text=”<div class=”timeline”>”; $additional_text .= ‘<a href=”‘; $additional_text .= the_permalink(); $additional_text .= ‘”><h3>’; $additional_text .= the_title(); $additional_text .= ‘</h3></a>’; $additional_text .= ‘</div>’; … Read more

Add custom css to theme

You need to make sure that your css goes between style tags. Try changing this line: .btn { background-color:<?php echo esc_attr($btn_color);?>; } <?php to <style>.btn { background-color:<?php echo esc_attr($btn_color);?>;</style> } <?php

Woocommerce – Checkout error message

you can try it for address not required . add_filter( ‘woocommerce_billing_fields’, ‘wc_optional_billing_fields’, 10, 1 ); function wc_optional_billing_fields( $address_fields ) { $address_fields[‘billing_address_1’][‘required’] = false; $address_fields[‘billing_address_2’][‘required’] = false; return $address_fields; }

Need to use an external variable inside a function

You’re right that using globals is inelegant at best. There are almost always better solutions that don’t depend on global variables. However, if you pause execution within your file_pull() function (e.g. using a debugger), or even just print $GLOBALS to your php error log within the scope of your function, does your $type variable show … Read more