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( ‘]]>’, ‘]]>’, $content ); $content = str_replace( … Read more

Add HTML before a specific div?

Seems like jQuery is best for this case. Mainly answering for myself in case I’ll need it again in the future: <head> <script src=”https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js”></script> <script> $(document).ready(function(){ $(“#this_comes_before”).insertBefore(“#wc_checkout_add_ons”); }); </script> </head> <body> <div id=”wc_checkout_add_ons”>stuff</div> <div id=”this_comes_before”>something</div> </body> Edit for future me: Use this instead you lazy asshole… add_action( ‘woocommerce_checkout_after_customer_details’, ‘test99’ ); function test99() { echo “your … Read more

the_content() not displaying the full post

Step 1 Disable all plugins and try enabling plugins, one by one, while you refresh the problematic page after each plugin enabled, until you find the source of problem. If no plugin was the cause, go to step 2. Step 2 Edit your current theme’s functions.php file and comment all occurrences of add_action(); add_filter(); function … Read more

Assign custom class to post content images

As you are using bootstrap you can add img-fluid helper class to images like this. function example_add_img_class( $class ) { return $class . ‘ img-fluid’; } add_filter( ‘get_image_tag_class’, ‘example_add_img_class’ ); get_image_tag_class filter allows to add custom css class along side WordPress default classes. Read more about the filter here

How to access & display images from a post without textual content ( and vice versa) according to best wordpress practices

This is really a CSS/HTML question as WordPress does not control your layout/styles. You can use one loop and fling the data wherever you want basically. For instance you can wrap individual functions in their own markup //loop start <div class=”left”><?php the_title(); ?></div> //float this title left <div class=”right”><?php the_content(); ?></div> //float this content right … Read more

How to parse without changing the characters case (lower and upper) in wordpress the_content?

Kitefr, (this isn’t really a WordPress question, but a php one) but you could usepreg_replace_callback, in which you define your own function to handle the the replacement. For instance, $text = “The quick brown fox jumped over the Quick dog.”; $text = preg_replace_callback( “/quick/si”, ‘my_replace’ , $text ); function my_replace($matches){ return ‘<strong>’.$matches[0].'</strong>’; } This replaces … Read more

custom field output after the_content

This is the answer – code to be added in the functions.php: add_filter( ‘the_content’, ‘my_the_content_filter’, 0 ); function my_the_content_filter( $content ) { if ( is_single() ) { global $post; $pgLnk=get_post_meta($post->ID, ‘Button’, true); $content .= ‘<div id=”button-link”><a href=”‘.$pgLnk.'” target=”_blank”> <span class=”button-link”></span></a></div>’; } return $content; } This code was wrote by @Sheikh Heera on stackoverflow.com – direct … Read more

In Loop Output Place Custom Field Content In Between Paragraphs

After researching this, here is what works for me: <?php $paragraphAfter= 1; //show box after selected paragraph $content = apply_filters(‘the_content’, get_the_content()); $content = explode(“</p>”, $content); for ($i = 0; $i <count($content); $i++) { if ($i == $paragraphAfter) { ?> <!– START OF BLOCKQUOTE –> stuff <!– END OF BLOCKQUOTE –> <?php } echo $content[$i] . … Read more

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