content and excerpt not displaying

I figured it out myself and it worked. Here is the code if anyone need any help. $the_query = new WP_Query(‘page_id=1’) ; if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ) { $the_query->the_post(); the_title(); the_content(); the_excerpt(); } } else { // no posts found } wp_reset_postdata(); Edit: This is working because the_content() and the_excerpt() have … Read more

IF Inside A Function For Content Filter [closed]

This should be it – <?php function my_the_content_filter( $content ) { if( get_post_meta( get_the_ID(), “heading_image”, true) ) { $image_id = get_post_meta( get_the_ID(), “heading_image”, true); $post_image_data = wp_get_attachment_image_src( $image_id, ‘full’ ); ?> // checks if you have got the source if( isset($post_image_data[0]) ) { // if image is show before the content $content=”<img src=””. $post_image_data[0] .'” … Read more

How can I output the content of the page using this code?

This is a “custom” loop outside of the main WordPress query (query_posts), you will have to tell WordPress to setup the post data using setup_postdata() More info on get_posts() is found here, giving you basically what I am about to write below: http://codex.wordpress.org/Template_Tags/get_posts Tip: The WordPress Codex is the best friend you will ever have, … Read more

Insert div after h2 in content

You’re right, you can do that with a filter (the_content). I attached an example. You can put that into the functions.php of your theme. function add_content_after_h2($content){ if (is_single()) { $div = ‘<div>small bit of content</div>’; $content = preg_replace(‘/(<\/h2>)/i’, ‘\1’.$div, $content); } return $content; } add_filter(‘the_content’, ‘add_content_after_h2’); Here you find the WordPress Codex with a detailed … Read more

strip_tags in get_the content

$content = get_the_content(); // regex (fixed) replacing ‘<embed>’ with ‘(embed )’ $content = preg_replace(“/<embed?[^>]+>/i”, “(embed) “, $content); // remove all tags $content = wp_strip_all_tags($content); echo $content; Edited according to the first comment: What you are trying to remove are not tags, these are HTML character entities. E. g., <p> was converted to &lt;p&gt; by WordPress … Read more

How do I show current post content in the header?

The simplest solution is to call the_post() to setup the post data before calling the template functions. <?php if(have_posts()) : the_post(); ?> //your header code here <?php rewind_posts(); //to set the post pointer back to the beginning ?> <?php else : ?> //alternative header code here <?php endif; ?>

tech