Best practices for multiple Custom Feeds functions

Here’s what I do to keep my RSS Templates together though depending on your version of PHP this may not work but it’s pretty clean. You can add multiple feeds here. /** Register Our RSS Feeds **/ function my_rss_templates() { add_feed( ‘feedname2’, function(){ get_template_part(‘rss’, ‘feedname2”); }); // Rinse and Repeat… } add_action( ‘after_setup_theme’, ‘my_rss_templates’ ); … Read more

wpautop – disable tags, keep tags

wpautop can ignore the linkebreaks if you use wpautop( $content, false ); To pass a parameter to wpautop via add_filter, use an anonymous function. This snippets seems to work for me if I add it to my theme’s functions.php: remove_filter( ‘the_content’, ‘wpautop’ ); $br = false; add_filter( ‘the_content’, function( $content ) use ( $br ) … Read more

PHP files included in functions.php don’t seem to work

I always break my functions.php up into more managable, specific functionality files, for instance, all footer related functions goes into a file called footer-functions.php and pagination functions goes into a file called pagination-functions.php. This way, my code stays organised, managable and I don’t kill my functions.php. This however, is only related to theme specific functions, … Read more

What will happen if I delete the functions.php file?

In all propability this infection is not restricted to functions.php only. Non WordPress files on your server might be infected as well as well as your wp-config.php and your db. Hackers do quite a good job when they hack a site. Simply deleting (which will in all propability break your site leaving you with WSOD) … Read more

Woocommerce checkout field maxlength, make input number field only (postcode)

By the time woocommerce_checkout_fields filter is run, the arrays for billing and shipping have already been created. You can see that here: https://docs.woothemes.com/wc-apidocs/source-class-WC_Checkout.html#101 If you want to effect the default fields, use this hook. function wpse215677_checkout_fields ( $fields ) { $fields[‘postcode’][‘maxlength’] = 4; return $fields; } add_filter(‘woocommerce_default_address_fields’, ‘wpse215677_checkout_fields’); If you want to adjust just the … Read more

How to filter out shortcode when displaying the_excerpt() in the loop?

try this add_filter( ‘get_the_excerpt’, ‘strip_shortcodes’, 20 ); or try this edit echo strip_shortcodes( get_the_excerpt() ); if shortcode is not register with wordpress function add_shortcode add_filter( ‘the_excerpt’, ‘remove_shortcodes_in_excerpt’, 20 ); function remove_shortcodes_in_excerpt( $content){ $content = strip_shortcodes($content); $tagnames = array(‘box’, ‘alert’); // add shortcode tag name [box]content[/box] tagname = box $content = do_shortcodes_in_html_tags( $content, true, $tagnames ); … Read more