Questions tagged [the-content]
Displays the contents of the current post. This template tag must be used within The_Loop.
53
questions
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 ...
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 ...
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 ...
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 ...
0
votes
2
answers
251
views
append_content help
i have a function in my plugin append_the_content($content) this is used to display my function inside the post, but it is coming before the post, i want to make it after the post, for this i tried ...
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 ...
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 ...
4
votes
2
answers
738
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 ...
3
votes
2
answers
4k
views
Filter to change the content of 404 page
I have created custom rewrite rules. These rules now go to 404 page as expected. I can use action hook template_redirect to change the template matching query_var.
But I don't want to create separate ...
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 ...
2
votes
3
answers
4k
views
Divide Post content into separate divs for every 500 characters (or any other character counts)
What is the best method for intercepting the_content of a post (for a single post page) and dividing the_content into sections of 500 characters (or any other number of characters), and then ...
1
vote
2
answers
883
views
How to apply content filter permanently?
I have the following temporary filter to fix a content error. We have data in our posts that have 4 digit zip codes, because the leading zero was cut when the original file was created. (For instance, ...
0
votes
1
answer
1k
views
How to prepend text to the_content, but after img/shortcode
I was trying to add some text to the beginning of every post (the text comes from post_meta, but for this example let's assume it's static text).
Here's what I tried:
add_filter('the_content', ...
25
votes
2
answers
95k
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 ...
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 ›','okay')); ?>
How i change the ...
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:
...
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 ...
6
votes
3
answers
5k
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') )
...
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....
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 ...
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? ...
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 ...
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 ...
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 ...
3
votes
1
answer
1k
views
Custom filter for the_content doesn't work correctly
=====THIS POST HAS BEEN UPDATED===== SCROLL TO THE BOTTOM TO READ THE UPDATE!
I asked a question yesterday that a gentleman named Tim was nice enough to take a stab at. He helped me through writing a ...
3
votes
1
answer
831
views
WordPress adding <br> tags into plugin content
We've written a plugin that shows reviews upon usage of a shortcode. On some sites, Wordpress is adding <br> tags throughout the shortcode content, and others it does not.
The shortcode works ...
2
votes
4
answers
14k
views
Use the_content outside the loop
I was trying to get first 100 words of the content in the header, and I use the following snippet to get the first 100 words in the loop, but is it possible to get the value outside the loop:
$...
2
votes
2
answers
10k
views
get_the_excerpt() not returning anything when post has no excerpt
When trying to call get_the_excerpt() the page does not return anything on posts that have no excerpt.
I thought WordPress usually 'fake' it and create one using the first x characters from ...
2
votes
2
answers
9k
views
get_the_content not working in loop?
I am trying to modify my loop to save post data by category. I found some code on this site that saved the post's titles based on their categories and tried to modify this to save the post's content. ...
2
votes
1
answer
278
views
Modify the_content after the more tag
I have created a custom plugin that pulls video and images out of a post and puts them into a nicely formatted set of galleries. The only problem is that the plugin doesn't allow me to put a video or ...
2
votes
1
answer
132
views
Changing the HTML Of the content
<?php the_content(); ?>
When we use the above the content is published like this →
<p>Content is published</p>
If I want to later this HTML and instead of <p></p> I ...
1
vote
2
answers
6k
views
What is the filter hook for custom fields content?
The following code hides "the_content" output
add_filter( "the_content", "cp_module_pcontent_post_content" );
function cp_module_pcontent_post_content($content){
global $post;
...
1
vote
2
answers
4k
views
How to ignore or disable nextpage tag?
I have this site that uses the <!--nextpage--> tag in posts for pagination purposes. I want to disable pagination, but without deleting the tags for the database (maybe they'll want to use them ...
1
vote
2
answers
2k
views
has_shortcode for content added after the content
I added some shortcode after the content using filter, like this:
add_filter( 'the_content', 'image_posts' );
but now that I run has_shortcode in another function, this returns false even though the ...
1
vote
1
answer
3k
views
Proper way to use get_the_content() in front-page.php and the content-home.php?
<div class="class1">
<ul>
<li>
<div class="class2">
<?php the_post_thumbnail( 'large') ?>
</div>
<...
1
vote
1
answer
5k
views
How to limit post content and remove image caption from it
I am using this function to limit the content in my themes. But the problem is whenever I call the function, it also displays the image caption. I want to remove the image caption when calling ...
1
vote
1
answer
4k
views
Is it possible to change the contents of "the_content()"?
I have moved a blog over to wordpress and I've used a lot of DOMDocument, xpath, regex and other methods to scrub the text.
This means that the_content(); is no longer the content and I'm using my ...
1
vote
1
answer
297
views
How to check if this is the nth instance of a given shortcode in a post
Suppose I have a shortcode called [item], which I have used 20 times in a particular post.
Is it possible, from within the shortcode handler function, to know what the numerical index of the given [...
1
vote
2
answers
684
views
Responsive class to all the images in the content
I have used this function to add a responsive class to all the images in content but this breaks the html structure of the website. This wraps the content with :
<!DOCTYPE html PUBLIC "-//W3C//DTD ...
1
vote
2
answers
306
views
Adding a form at the end of the content
I'm trying to add a little form after each post for a plugin I have to code, but I'm not very familiar with Wordpress. By using add_action with the_content as hook, I was able to add some text to the ...
1
vote
2
answers
4k
views
Get link value only from the_content()?
I have my news in posts and I am trying to display the two latest news articles (posts) on my main page. I've got that solved by getting the title using the_title() and getting a little bit of the ...
1
vote
1
answer
3k
views
add data-attribute to all images inside the_content()
I wonder if it's possible to add a filter to all images inside the_content() to create the following image pattern for all images …
<img class="digest" src="smallest-file.jpg" data-fullsrc="...
1
vote
1
answer
7k
views
shortcode not working and the relation to the_content()
Reference Post (I was even downvoted here.)
My short code was not working on my custom theme, but the same short code, when used in twenty fifteen, was working.
I researched over google and found ...
1
vote
2
answers
3k
views
How to encode post content as JSON?
I`m trying to construct a json object but are having difficulties with the_content since it returns newlines, which causes the script to fail. The error messages received is: Uncaught SyntaxError: ...
1
vote
2
answers
241
views
Accessing Media/Files outside the_content
I'm building a site and each post has a PDF file attachment. Is there a way I can access that file outside the_content() on a single post page? I'd like to put the file attachment in a sidebar and not ...
0
votes
1
answer
1k
views
Post content being duplicated by the_content();
I have a query that runs through a set of posts with the post type location. It returns them broken down by a custom field value (in this case, the state in which the location is located). For some ...
0
votes
3
answers
4k
views
How to output only the post content
How can I output ONLY the post content (ie the text entered into the wysiwyg) and nothing else? i just need this for the posts in a specific category, so if i could call like say,
<?php ...
0
votes
1
answer
1k
views
How to hide <pre> and <table> content from auto-generated excerpts?
Auto-generated excerpts just take the first x characters from the post content and cut that off at a certain point.
When there is a table or pre element in that part, the excerpt looks rather useless ...
0
votes
1
answer
449
views
How do I assign this filter to a variable? (Appending php & markup to the_content)
===I HAVE SOMETHING THAT WORKS NOW, JUST NOT CORRECTLY. PLEASE READ THE WHOLE POST, I AM GOING TO LEAVE IT ALL UP HERE BECAUSE OTHERS MAY BE ABLE TO BENEFIT FROM ME BUMBLING THROUGH THIS PROCESS!!
I ...
0
votes
1
answer
621
views
Wp-query causing problems with the_content();
I'm using some code provided in an answer on here to calculate "post X of Y" and display pagination icons on single.php.
It works beautifully but it's causing problems displaying the_content();
On ...