Adding a div class or id inside the_content()

You have to put your advertisement block just before <?php the_content(); ?> in a separate div-layer and add some css to it. E.g. single.php <div class=”entry entry-content”> <div class=”advertisement”> <p>Your advertisement</p> </div> <?php the_content(); ?> </div> CSS div.advertisement { float: left; width: 150px; padding: 0px 10px 10px 0px; }

Static page homepage not showing the_content

You don’t really have a Loop. <?php get_header(); ?> <div class=”content”> <div class=”welcome_area”> <div class=”welcome_area_title”><?php the_title(”);?></div> <div class=”welcome_area_text”><?php if (have_posts()) { while (have_posts()) { the_post(); the_content(); } } ?> What is happening is: You use have_posts() to check that you have post content. You can use an else clause to provide default content if you … Read more

What params are available with the_content filter?

I don’t think there are any additional parameters passed, per se, to the_content, but global variables like $post are accessible. So something like this would work: add_filter( ‘the_content’, ‘check_for_post_parent’ ); function check_for_post_parent($content) { global $post; if ($parent_id == $post->post_parent) { //do what you want to $content here, //now that you know $parent_id //… } return … Read more

Insert Ad Code in the Middle of a Post

This function inserts your ad code after the specified paragraph. add_filter(‘the_content’, ‘wpse_ad_content’); function wpse_ad_content($content) { if (!is_single()) return $content; $paragraphAfter = 2; //Enter number of paragraphs to display ad after. $content = explode(“</p>”, $content); $new_content=””; for ($i = 0; $i < count($content); $i++) { if ($i == $paragraphAfter) { $new_content.= ‘<div style=”width: 300px; height: 250px; … Read more

How to to stop html editor from addig tags to shortcodes, images, etc

1. Filtering the content Here’s a one-function content filter to meet the above four requirements: add_filter( ‘the_content’, ‘strip_some_paragraphs’, 20 ); function strip_some_paragraphs( $content ) { $content = preg_replace( ‘/<p>(([\s]*)|[\s]*(<img[^>]*>|\[[^\]]*\])[\s]*)<\/p>/’, ‘$3’, $content ); return $content; } 2. Resources for Regular Expressions regular-expressions.info – Manual, Basic & Advanced Tutorials regexpal.com – on the fly regex tester, very … Read more

add_filter for specific pages

It is helpful to post your entire filter and callback code, rather than just pieces. But, I suspect that the problem is that you’re not returning $the_content outside of your conditional, e.g.: function magicalendar_get_event_page( $content ) { if ( $post->post_name == ‘magicalendarpage’ ) { // Do something to $content return $content; } } add_filter( ‘the_content’, … Read more

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