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);

Which action/filter can i use for a Member Plugin [closed]

You could try this: function restricted_access() { if( ! is_user_logged_in() ) { global $wp_query; $wp_query->set_404(); status_header(404); } } add_action( ‘wp’, ‘restricted_access’ ); By default, always, if the user is not logged in it will give them the 404 page. The following two functions will keep non-admins out of your Admin Panel and will also hide … Read more

How can I customize the_content(); output? [closed]

You can add a filter to the content directly on functions.php and use str_replace or perhaps some preg_replace (regex) to change the output of the content. Not tested. Try something like this: function add_class_to_img_and_p_in_content($content) { $pattern =”/<img(.*?)class=\”(.*?)\”(.*?)>/i”; $replacement=”<img$1class=”$2 newclass newclasstwo”$3>”; $content = preg_replace($pattern, $replacement, $content); $pattern =”/<p(.*?)class=\”(.*?)\”(.*?)>/i”; $replacement=”<p$1class=”$2 newclass newclasstwo”$3>”; $content = preg_replace($pattern, $replacement, $content); … Read more

Create a shortcode to display the “the_content ()” in my post [closed]

Here is an example of a shortcode that renders post content based on the id and type attribute. [post type=”content” id=”2″] [post type=”title” id=”2″] If you want to render from a template you would use: echo do_shortcode ( ‘[post type=”content” id=”294″]’ ); echo do_shortcode ( ‘[post type=”title” id=”294″]’ ); And here is the actual shortcode … 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; }

Adding schema to text content in the loop, how?

Just add them to echo <?php if ( has_post_thumbnail() ) { the_post_thumbnail( ‘full’, array( ‘class’=>’post_thumbnail_common’, ‘alt’ => get_the_title() , ‘title’ => get_the_title(), ‘itemprop’=>’image’ ) ); echo ‘<div itemscope itemtype=”http://schema.org/BlogPosting”>’.contentnoimg(41).'</div>’; } else { echo content(41); } ?>

How to remove only images from the_content() [duplicate]

This answer already here How to remove images from showing in a post with the_content()? <?php $content = get_the_content(); $content = preg_replace(“/<img[^>]+\>/i”, ” “, $content); $content = apply_filters(‘the_content’, $content); $content = str_replace(‘]]>’, ‘]]>’, $content); echo $content; ?>

How add class the_content();?

You don’t. You’ll need to put an element around it: <?php if ( $content_source == ‘excerpt’ ) { ?> <div class=”excerpt”> <?php the_excerpt(); ?> </div> <?php } else { ?> <div class=”content”> <?php the_content(); ?> </div> <?php } ?>

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)