append PHP function to the_content

You will need to experiment with priority. add_filter( ‘the_content’, function($content) { return ‘text-to-append’ . $content; }, 10 // this is a priority number; 10 is default ); The “10” is the default priority. I don’t know what number JetPack uses but your original code, without a priority, should run at “10” so I’d try “9”, … Read more

How do I assign this filter to a variable? (Appending php & markup to the_content)

Congratulations on (nearly) solving your problem already 🙂 There are 2 comments below the post that attempt to say how to do it the right way They are proposing to do it this way: function weedub_affiliate_filter($content) { $string_to_add = ”; if (is_single()) { $string_to_add = $string_to_add . ‘the string you wanted to add’; } $content … 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

Changing the HTML Of the content

The wrapping <p> is applied by a filter called wpautop. You can disable this filter and wrap the content in your desired wrapper, but it’s not really recommended. remove_filter( ‘the_content’, ‘wpautop’ ); remove_filter( ‘the_excerpt’, ‘wpautop’ ); Now you can wrap your content in a DIV for example: <div><?php the_content(); ?></div> But notice that this filter … 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

add data-attribute to all images inside the_content()

You will need to take a look at the image_send_to_editor filter. This will not update existing records but it if you get it working it will apply to each newly inserted image. very basic filter: function give_linked_images_class($html, $id, $caption, $title, $align, $url, $size, $alt=”” ){ $html; //contains the string you need to edit, you might … Read more

Adding a form at the end of the content

If I understand what you are doing, and the problem you are having, the first thing I’d try is to add your the_content filter with a large priority number so that it runs late, and hopefully after the other formatting filters. add_filter(‘the_content’,’your_callback’,100); If that doesn’t do it you may have to remove and reorder some … Read more

Accessing Media/Files outside the_content

Try the following code: $args = array( ‘post_type’ => ‘attachment’, ‘numberposts’ => -1, ‘post_status’ => null, ‘post_parent’ => $post->ID ); $attachments = get_posts( $args ); if ($attachments) { foreach ( $attachments as $attachment) { setup_postdata($attachment); the_title(); the_attachment_link($attachment->ID, false); the_excerpt(); } }

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