Skip to main content

Questions tagged [the-content]

Displays the contents of the current post. This template tag must be used within The_Loop.

Filter by
Sorted by
Tagged with
38 votes
11 answers
34k views

Stop Wordpress Wrapping Images In A "P" Tag

I have searched high and low for a simple solution to this, but to no avail. Wordpress keeps on wrapping my images in p tags and because of the eccentric nature of the layout for a site I am working ...
Dwayne Charrington's user avatar
28 votes
3 answers
71k views

How to get 'post_content' without stripping <p> tags?

I'm trying to retrieve the post content of a specific post: $post = get_post(/* id */); $content = $post->post_content; However, this retrieves the content with no line-breaks and omits all <p&...
Lisandro Vaccaro's user avatar
25 votes
2 answers
97k views

apply_filters('the_content', $content) vs do_shortcode($content)

Lets say I have a theme option or custom postmeta text area. Now I want to execute multiple shortcodes, general texts, images etc. What will be best practice and why? Option 1: $content = //my text ...
тнє Sufi's user avatar
  • 1,710
23 votes
3 answers
15k views

Split Content and Gallery

Is there a way to split up the post content and the gallery short code. I want to display the gallery outside my normal content no matter how or where it is placed. I can use this to get the shortcode ...
Howdy_McGee's user avatar
  • 20.7k
15 votes
3 answers
3k views

the_content and is_main_query

I am filtering the content with the the_content filter. Everything works perfect, excerpt that my changes are applied to custom queries as well. My changes appear in the sidebar as well if the widget ...
Pieter Goosen's user avatar
12 votes
1 answer
15k views

How can i display the content in plaintext

i want to display my excerpt in plaintext. How can i do this? This is my Snippet where i display the content: <?php the_content(__( 'Weiterlesen &rsaquo;','okay')); ?> How i change the ...
ScienceNoob's user avatar
11 votes
1 answer
3k views

Change appearance of shortcode text inside editor

Is it possible to change appearance of shortcodes in editor or in whatever way make it more distinguishable from surrounding text? For example if the content of a post is like this... Reference ...
Ivan Topić's user avatar
11 votes
4 answers
71k views

Get content from one page and show it on another page

So, I've been googling and reading and testing and failing. I'm fairly new to php, so don't expect to much :) I'm working on a new design, and I want to show content from the about page on my ...
Stian's user avatar
  • 113
10 votes
1 answer
20k views

post_content with line breaks

I want to be able to get post_content with line breaks. What is the best way to do it? I previously use the_content() which was working fine until I needed to install a plugin that adds share buttons ...
Charles Wayne's user avatar
10 votes
2 answers
15k views

Only show content before more tag

I am using the Siren Template. In homepage.php this code is used to display the portfolio content print_excerpt(200); But I to need show the content only before <!--more--> I have used this: ...
MajidGh's user avatar
  • 103
10 votes
2 answers
14k views

How to appending to the_content using add_filter with custom post type?

I have a custom post type running fine, but some of the text in the page is the same for every post, so I want to add it in using a function. I have this set up: function new_default_content($...
George C's user avatar
  • 255
8 votes
3 answers
18k views

How to wrap an element around an iframe or embed in content automatically?

Id like to have wordpress automatically wrap a div around any iframe or embed when they are used in the_content...how might this be achieved?
Mr.Brown's user avatar
  • 1,025
8 votes
12 answers
62k views

remove <p> tags from the_content

I've got a post format of Image, and I am running into an issue where the image is being wrapped by a <p> tag. I want to get rid of that tag (specifically on the single.php version) of those ...
Jon Mitten's user avatar
8 votes
2 answers
469 views

WordPress Internal @ Mentions

I'm looking for a way to link to author pages within one WordPress install simply by putting the @ symbol in front of a person's username in a post.... just like on twitter. Example: If the username ...
AndrettiMilas's user avatar
8 votes
2 answers
22k views

why doesn't the_content() work in this {single-custom_post_type.php} page?

This code is from my page single-publication.php. It outputs the relevant custom fields etc (here wrapped in template tags), but the_content() won't output the post content. I've resorted to using $...
djb's user avatar
  • 2,250
8 votes
2 answers
12k views

Are content.php and content-single.php the same?

I understand that when using get_template_part('content', get_post_format()); it will help choosing a post format for specific page according to post format. And if there is no post format 'i.e it's ...
Eibo's user avatar
  • 247
7 votes
4 answers
29k views

Removing any and all inline styles from the_content()

For one of my current projects, I had to transfer blogposts from an old Wordpress site to my project. Things went smoothly until I've seen that all the posts were copy pasted from Word, leaving this ...
Fredy31's user avatar
  • 868
7 votes
3 answers
59k views

Why is the_content() not displaying the content? [closed]

in my wordpress site, the_content() is not showing the content, but $post->post_content shows it, why this is happening? and how can I use the_content again?
srisar's user avatar
  • 261
7 votes
2 answers
12k views

Where to hook into post content?

Which hook or filter is used to edit the post content before the_content filter is applied to it. For instance, if I wanted to add Hello World, as the first text in every post.
rob-gordon's user avatar
7 votes
2 answers
14k views

Difference between the_content() and get_post()?

I'm working on tweaking a theme and I need to explode the post content to remove some text. The following code is what I am using: $custom_Get_Post_Title = explode('|',get_post()->post_content); ...
thatsgreyt's user avatar
6 votes
3 answers
6k views

Hook added to the_content seems to be called multiple times

I have the following code running in a plugin: add_filter('the_content','thousand_pay'); //Callback function function thousand_pay($content) { echo $content; if( !in_category( 'Stories') ) ...
Ed King's user avatar
  • 63
6 votes
1 answer
5k views

Add something to beginning of the content

I'm using add_action('the_content', 'myFunction', 10) to append data to the end of the content. How can I place content at the beginning of the content?
N2Mystic's user avatar
  • 3,183
6 votes
2 answers
1k views

Insert Custom HTML After Shortcode

The scenario is that I need to add an HTML banner under a slideshow which is a shortcode in the homepage content. I personally hate adding a bunch of div tags to the TinyMCE editor so I'm trying to ...
Howdy_McGee's user avatar
  • 20.7k
6 votes
1 answer
2k views

Using preg_replace to separate gallery from the_content?

In a Wordpress theme, I need to separate a gallery from the rest of the_content. I think one could do that with get_the_content and preg_replace but it's a little beyond my skill level how to actually ...
Josh M's user avatar
  • 342
6 votes
3 answers
6k views

Remove specific shortcode from get_the_content()

I have a variable like this: $post_content = get_the_content(); Here I want to remove some specific shortcode from the $post_content variable e.g I want to remove only this [video height="300" width=...
Faisal Khurshid's user avatar
5 votes
3 answers
49k views

How can i remove all html tags from get_the_content()?

i want to remove all html tags from content like <p>, <br>, <img>, <a> i tried strip_tags() also tried $content = get_the_content(); $content = apply_filters('the_content', $...
Muhammad Furqan's user avatar
5 votes
1 answer
16k views

Get excerpt from $post->post_content

I am modifying the output of a plugin using a filter, and the $post variable is available to me, so I can display the post content like so: <h3><?php echo $post->post_title; ?></h3&...
LBF's user avatar
  • 529
5 votes
1 answer
1k views

Content over 10,000 characters won't display with the_content()

A friend of mine just noticed that their site wasn't displaying pages that had a lot of content. For some reason they are just blank, and if he removes some content from the page it will display again....
Chris Schmitz's user avatar
5 votes
1 answer
515 views

Add whitespace between Chinese and other letters

I want to add a space between a Chinese character and a letter or a number to make the article more readable. For example: Google与Apple展开的专利大战在2天之前结束。 Google 与 Apple 展开的专利大战在 2 天之前结束。 But add the ...
比尔盖子's user avatar
4 votes
3 answers
13k views

How to disable content pagination?

I want to totally disable this functionality from WordPress because I'm implementing my own version of this with Javascript. When I try to grab all the content in a post via the get_the_content() or ...
ninja08's user avatar
  • 147
4 votes
4 answers
10k views

Modify 'Read more' link adding a new class

I want to add a class to the 'Read more' link. Actually I have this: <?php the_content( 'Read more...' ); ?> Which outputs: <a href="...?p=14#more-14" class="more-link">Read more…</a&...
Alvaro's user avatar
  • 2,583
4 votes
3 answers
27k views

Adding a div class or id inside the_content()

I'm trying to create an advertisement block to be placed on a single post (single.php) such that the div class or id is left aligned and the post content wrapped around it. I checked the single.php ...
swordfish81's user avatar
4 votes
2 answers
1k views

Using variable from one filter in another filter

I have a filter for the Gallery Shortcode where I grab IDs for images used in a post and using the IDs I grab their meta data. Now I need a way to use the $copyright variable in a filter for grabbing ...
Ivan Topić's user avatar
4 votes
1 answer
12k views

Add Class to Specific Paragraph of the_content()

Let's say I want to give the first paragraph bold text by adding a body class to the first paragraph. Is there a way to filter the output of the_content(); or any other paragraph? First paragraph? ...
jw60660's user avatar
  • 1,516
4 votes
5 answers
13k views

How do I add the featured image to the_content after the first paragraph?

My problem: I'm trying to create a filter that will add the featured image of a post to the_content, so that I can have the first paragraph of the_content displayed before this image. What I basicly ...
Anders's user avatar
  • 53
4 votes
2 answers
7k views

the_content after all shortcodes are parsed

I am creating a WordPress Plugin for WordPress directory. How can I get the_content() after applying all the shortcodes that are presents in the_content? Let me explain: My plugin will be used in ...
kuldip's user avatar
  • 41
4 votes
2 answers
741 views

Heartbeat API oEmbed

By default running content through the_content filter automatically checks for oEmbed content. However when returning data through heartbeat_received the filter for oEmbed doesn't seem to work. For ...
Elliott's user avatar
  • 542
4 votes
2 answers
18k views

limit the words in the post content and add read more link

As you can see into the code, the routine is to display the post which has an id of 266. Now all I want is to limit the words displayed in the post content of that post. Let's say, I want to limit the ...
Juliver Galleto's user avatar
4 votes
1 answer
19k views

add_filter for specific pages

Is it possible to add this filter add_filter("the_content", "magicalender_get_event_page"); But only for one specific page, for example if($post->post_name == "magicalenderpage") If I put the ...
Stephen Cook's user avatar
4 votes
1 answer
231 views

Return the_content() with custom div class for a subset of posts

Is it possible to have the_content() function return the post content in a div with a custom CSS class (i.e. something other than the-content)? I have a unique post I'm trying to lay out that requires ...
Geoff's user avatar
  • 41
4 votes
1 answer
3k views

Apply the_content filter for specific post types only

I'm trying to modify a snippet of code I found here for a wordpress website: http://support.membermouse.com/support/discussions/topics/9000007386 Here is the code: <?php add_filter( 'the_content',...
user92240's user avatar
4 votes
3 answers
5k views

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

I know this this is covered as individual topics but What I am looking for is a single function that stops <p> tags from being wrapped around via the Wordpress editor to shortcodes and images ...
Jason's user avatar
  • 606
4 votes
1 answer
3k views

Is it possible to remove next-post / previous-post with out creating a custom template?

I'm creating a plugin that uses a custom post type. I do not want to make a custom template for viewing the posts and discovered I can add a filter for the_content to include my custom fields, this ...
Jason M's user avatar
  • 43
3 votes
2 answers
13k views

Insert Ad Code in the Middle of a Post

I want to insert an ad code in the middle of a post via functions.php. I found several links but either they don't use functions.php or don't insert the code in the middle. Can anyone tell me how to ...
Elmo's user avatar
  • 191
3 votes
2 answers
4k views

What params are available with the_content filter?

I am looking for what params are passed to my filter function. Where can I find such info in the codex? http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content didn't provide much info I ...
JM at Work's user avatar
  • 2,323
3 votes
2 answers
17k views

Static page homepage not showing the_content

I must be doing something wrong here. I setup my site with a static front page using front-page.php. I created a page in the admin with a title and chose the front-page.php in the template dropdown. ...
dragonfeet2012's user avatar
3 votes
1 answer
1k views

the_content and wp_link_pages

Many plugins seem to be adding a filter/action hook to the_content to display related posts, advertisements and such. The problem is I these appear before the post pagination so it the pagination is ...
Jürgen Paul's user avatar
3 votes
1 answer
11k views

apply_filters('the_content', $content) alternative

"the_content" filter can get added with other filters from plugins and themes which could alter content, when you simply want this to format the post_content to HTML format. Is there a better ...
ashanjay's user avatar
3 votes
4 answers
6k views

How to add an inline style to the <p> tag outputted in the_content() using PHP?

I am trying to add an inline style to my paragraph tags which are ouputted using the_content(); I've tried string replace, see question I did earlier. But it won't because the_content echo's it and ...
Joshc's user avatar
  • 1,520
3 votes
3 answers
6k views

Filter Gutenberg Blocks Content

I have a simple terms page made up of heading and paragraph blocks. I'd like to filter the_content before output in order to get the content of any heading blocks and create a menu with links to named ...
Kevin Nugent's user avatar

1
2 3 4 5
12