How I can show short content with short tag

function abc_the_content($num_words) { global $post; $content = $post->post_content; $content = strip_tags($content); $content = wp_trim_words($content, $num_words, $more = null); echo apply_filters(‘the_content’, $content); } change the strip tags line to this one if you want to strip out only the img tag $content = preg_replace(“/<\/?img(.|\s)*?>/i”, ”, $content);

Adding jquery using php function

Why are you not using the built-in enqueue_script function? Simply put your custom jQuery code into a file called custom.js, save it into your plugin or theme folder, then enqueue it with jQuery as a dependency: <?php function custom_scripts() { if (is_admin()){ wp_enqueue_script( ‘customjs’, get_template_directory_uri() . ‘/js/custom.js’, array(‘jquery’) ); } } add_action(‘wp_enqueue_scripts’, ‘custom_scripts’); You’ll need … Read more

Custom single-product page for product from category x

Assuming that the taxonomy you want to check is product_cat and the term for which you want change template is special and finally assuming that the file you want to use for this special category is named special-single-product.php and resides in the root of your theme, the code you have to use is: add_filter(‘template_include’, ‘special_single_product’); … Read more

WordPress Home page modification [closed]

Not sure what you are asking. You don’t want anything on the homepage of your site? You can remove the widgets (the left side) in Appearance > Widgets in your admin. The Leave a Reply box looks like comments, which can usually be turned of on a page or post.

How to make a page extend full screen [closed]

Do you understand the bootstrap framework at all? Your theme has implemented a column width that is smaller than you would probably like. Your content area is wrapped in an offset column that is 50% of the container width. <div class=”col-lg-6 col-lg-offset-3″> <!– content –> </div> If you want to increase the width of your … Read more

iHow to redirect all http traffic to https now that a SSL certificate is added?

You can replace your URLs in PHPMyAdmin instead – make sure you have backed up your database though. You’d need to change this code and run it: UPDATE wp_posts SET guid = replace(guid, ‘http://www.old-url.co.uk’,’https://www.new-url.co.uk’); UPDATE wp_posts SET post_content = replace(post_content, ‘http://www.old-url.co.uk’, ‘https://www.new-url.co.uk’); You might be able to bypass this step if you have a secure … Read more

Disable Woocommerce checkout based on user role [closed]

Woocommerce is considered off-topic here but as a general answer, it is considered best practice to check against capabilities instead of roles In WP, this is done like that: add_action(‘init’, ‘wpse_capability_check’); // hooked on ‘init’ but depends on your actual code logic function wpse_capability_check(){ // you should check on a capability that only validated user … Read more

Force array to be a string [closed]

There are a few ways you can make an integer a string. Here are 2 main ways to make that happen Type Cast – $values_x[] = (string) $series[0][‘data’][$i][0] Double Quote – $values_x[] “{$series[0][‘data’][$i][0]}” Also, you might want to check for null first and assign a default $values_x = !empty($values_x) ? $values_x : array(‘2010’); If you … Read more