Proper use of the_content filtering

You want to add a filter to the filter queue on the_content: add_filter(‘the_content’, ‘anything’); WordPress core then calls apply_filters within the_content function to run all filters in the queue: function the_content( $more_link_text = null, $strip_teaser = false) { $content = get_the_content( $more_link_text, $strip_teaser ); $content = apply_filters( ‘the_content’, $content ); $content = str_replace( ‘]]>’, ‘]]>’, … Read more

Add span to the first letter of post

This drop caps plugin does what you are looking for: http://wordpress.org/extend/plugins/drop-caps/ If you’re trying to do drop caps this should be enough. If you want to do more you could look into the code and see how the plugin wraps the 1st char in a span. It probably uses preg replace too. Id look myself … Read more

tag the_content()

WordPress inserts p tags in the_content(), otherwise it would be rather difficult for your content to contain more than one paragraph. If you want to target the p WordPress inserts, just change your css to: .page_content p { text-align:justify; float:left; } and remove your wrapping <p> tag.

preg_replace Remove comment text in content

The problem you are having with your code is this line: $conten = preg_replace(“/<!–REMOVE–>.*<!–ENDREMOVE–>/”, ”, $content); $conten is assigned, but $content is returned. function remove( $content ) { return preg_replace( ‘/<!–REMOVE–>.*<!–ENDREMOVE–>/’, ”, $content ); } After question edit: The real result from above code is abc acb acb acb abc acb acb acb .* is … Read more

the_content() isn’t showing content, but $post->post_content does

After the <ul> part you do reset the query, but you also have to reset the original postdata: wp_reset_postdata(); and in the line <li> <a href=”https://wordpress.stackexchange.com/questions/77494/<?php the_permalink(); ?>” <?php if (!isset($_GET[‘tab’])) {echo “class=com_sel”; $page = “אודות הקבוצה”;} ?>>אודות הקבוצה </a> </li> the php and if tags are mixed up, i don’t know if PHP understands … Read more

How can I show the actual content of Posts page because the_content() is showing all blog content?

You can use: get_queried_object_id() to get the ID of the static posts Page. Alternatively, you may also use get_option( ‘page_for_posts’ ). $post_id = get_queried_object_id(); //$post_id = get_option( ‘page_for_posts’ ); // you should use the above on the blog page $content = get_the_content( null, false, $post_id ); get_queried_object() to get the full data of the static … Read more

How I can split text in the_content() into 2 columns?

Did you try css? <div class=”columncontent”> <?php the_content(); ?> </div> Then the css: .columncontent { column-count: 2; } Depending on your theme, you could just find a div already surrounding your content too. There is all sorts of magic there! https://www.w3schools.com/css/css3_multiple_columns.asp The only thing I would suggest is that you use media queries, as the … Read more

How to output only the post content

Assuming you are in the loop, or otherwise know (or know how to get) the $post object: function wpse63358_get_post_content() { global $post; return $post->post_content; } If you want the formatted post content, replace this: return $post->post_content; …with this: return apply_filters( ‘the_content’, $post->post_content ); To echo the function output: echo wpse63358_get_post_content(); Edit Note: if you just … Read more

How to encode post content as JSON?

To output JSON always the function json_encode( $string ). The function is not available on all hosts. Don’t worry, WordPress offers a fallback in wp-includes/compat.php. That’s a wrapper for class Services_JSON::encodeUnsafe() (see wp-includes/class-json.php). If you take a look at the source you’ll see: It’s not a trivial job to encode a string. 🙂 There is … Read more

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