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 function to function.php error 505 [closed]

Editing your functions.php file is high risk, specially if it is a theme you acquired through purchasing or downloaded. There a several risks in doing that, firstly, just one simple syntax error, and site crash, like you explained. Secondly, if you upgrade the theme, all your changes will be lost. You won’t have that problem … Read more

How can I json_encode the output of my function?

Not sure if the get_all_images() function is the one that is added to your wp_ajax_{action} hook. If it is you will want to output a string back to your js. I would define a variable and concatenate the img html to it as you loop through your images. function get_all_images() { //your code $response=””; foreach($images … Read more

PHP error in shortcode [closed]

You are not using proper syntax, so you are likely getting a syntax error. You are using some strange sign in your code where you should be using a single quote (‘). Also, use curly brackets to enclose a condition. It is easier to debug <?php if(function_exists(‘wooslider’)){ echo do_shortcode(‘[wooslider slider_type=”posts” limit=”3″ link_title=”true” layout=”text-bottom” overlay=”full” category=”homepage-feature-post”]’); … Read more

Creating mixture of shortcodes to use in the visual/text editor

I suggest to just append the other things to the content without editing the templates add_filter(‘the_content’,’hang_my_specific_things_on_the_content’); function hang_my_specific_things_on_the_content($content) { // shortcode0 is appended before content $content = do_shortcode(‘[shortcode0]’).$content; // these are appended after the content $content .= do_shortcode(‘[shortcode1]’); $content .= ‘<img src=”https://wordpress.stackexchange.com/questions/312880/someimage.png” />’; $content .= do_shortcode(‘[shortcode2]’); return $content; }

Missing argument 2

You t2t_homepage_slide($slide,$size) function requires 2 arguments and your only calling it with one. Either include the $size argument when calling the function or remove the requirement or provide a default when defining the function (line 94). eg: function t2t_homepage_slide( $slide, $size=””) { <— line 94 global $wpdb; $image = get_option($slide); $caption = get_option($slide.’_caption’); $price = … Read more

Save output of the_content_rss into variable

the_content_rss() is deprecated. You should be using the_content_feed(), but that is a secondary problem. Both functions echo content. What you want is the get_* variant– get_the_content_feed(). That is a general rule, by the way, but not a 100% consistent one. Many functions starting with the_ will output content immediately and there tends to be a … Read more