Adding php directly into widget shortcode

To be honest, if you see yourself in the need of adding executable PHP code into a shortcode attribute, or in content editor in general, you are doing something wrong. You should think again about what, why and how do it. There is a high security risk accepting executable PHP code form user inputs. Instead, … Read more

Setting up the child theme so as to enable right-to-left WordPress?

You also need to include the RTL.css file which is in the theme too: add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_styles’ ); function my_theme_enqueue_styles() { wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ ); wp_enqueue_style( ‘rtl-style’, get_template_directory_uri() . ‘/rtl.css’ ); } To use the rtl.css from your theme directory change the code to: add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_styles’ ); function my_theme_enqueue_styles() { wp_enqueue_style( ‘parent-style’, … Read more

append PHP function to the_content

You will need to experiment with priority. add_filter( ‘the_content’, function($content) { return ‘text-to-append’ . $content; }, 10 // this is a priority number; 10 is default ); The “10” is the default priority. I don’t know what number JetPack uses but your original code, without a priority, should run at “10” so I’d try “9”, … Read more

Update Custom Field on Imported Post Creation

There is a hook that worked for me in most case while those 3 hooks you use fail. It’s transition_post_status : add_action(‘transition_post_status’, ‘sterilize_vehicle_information’, 10, 3); function sterilize_vehicle_information( $post, $new_status, $old_status) { $internet_price = get_field(‘internet_price’,$post->ID); if( $new_status == ‘publish’ && old_status != ‘publish’ ) { update_post_meta( $post->ID, ‘internet_price’, preg_replace( “/[^0-9]/”, “”, $internet_price ) ); } } … Read more

Post from one loop in different containers?

<?php $class=””; // set your class to nothing outside the loop ?> <?php if (have_posts()) : while ( have_posts()) : the_post(); ?> <?php $class = (‘first-container’ == $class) ? ‘second-container’ : ‘first-container’; // alternate classes ?> <div <?php post_class(‘clearfix’) ?> id=”post-<?php the_ID(); ?>”> <h2><a href=”https://wordpress.stackexchange.com/questions/77704/<?php the_permalink() ?>”><?php the_title(); ?></a></h2> <div class=”<?php echo $class ?>”> If … Read more