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

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

Find and replace weird characters in the_content [closed]

You could try this: <?php function replace_content($content) { $search = array(‘&’, ‘é’, ‘—’, ‘‘’, ‘’’, ‘“’, ‘”’); $replace = array(‘&’, ‘é’, ‘—’, ‘‘’, ‘’’, ‘“’, ‘”’); $content = str_replace($search, $replace, $content); return $content; } ?> Credit to Harry on WordPress forums

Exactly where I have to insert get_next_post_link() in a post?

When you develop a theme you can add specific styling per each post type. by default they all use the single.php theme file, but single-{post-type}.php will be used for the specific post type being displayed (for the full template hierarchy – https://developer.wordpress.org/themes/basics/template-hierarchy/#the-template-file-hierarchy) The navigation links like the prev and next ones you are trying to … Read more

How to replace text in hompage only

the_content(Read more …’) echoes the stuff straight out so you can’t modify it with str_replace after the fact. If you wanna use str_replace you need to do something along the lines of $content = get_the_content( ‘Read more …’ ); $content = apply_filters( ‘the_content’, $content ); $content = str_replace( ‘]]>’, ‘]]&gt;’, $content ); $content = str_replace( … Read more

tech