Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

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
1
vote
2answers
776 views

Remove Content Filter

I need help with removing the Content Filter from a Plugin: add_filter( 'the_content', array( &$this, 'addContentAds' ), 8 ); Do someone could help me please? Thank you and best regards
-1
votes
0answers
21 views

PHP DOM Element failing to handle HTML tag like strong, anchor, div etc

We have exactly the same problem as this. I have used this code in my project and it is working fine but the problem is that I want to load all HTML tags which are available in that div tag like a ...
0
votes
1answer
25 views

What are the advantages/disadvantages of using jQuery DOM manipulation as opposed to PHP DOM manipulation?

I'm working on a plugin that takes $content for a post and alters some of the HTML. Seems there are two common ways to accomplish this in WordPress - using jQuery or using PHP's DOMDocument. I'm ...
0
votes
1answer
24 views

Error shown for Trying to get property 'roles' of non-object in Wordpress After Content for User Roles

I have been struggling to code a function, which echoes a code, when the user role is 'administrator' or is um_verified' Honestly I don't know much of what it means, but still, I want to solve this ...
0
votes
1answer
23 views

Add shortcode inside of the_content()

I have a custom post type (events) and i made a custom template for archive and for single. On single i want to add a shortcode to every post, this shortcode provides all dynamic data of the current ...
0
votes
2answers
651 views

how to use custom loop in the_content filter

Trying to use the the below code for my CPT 'state' like add_filter('the_content', 'my_custom_loop'); but the trial and error is not getting me anywhere. I can't use a single-{post_type}.php since i ...
0
votes
1answer
15 views

Undefined variable error in new function

I wanted make function to count the time last the user read the article but after putting it in fuctions.php I see this error: Notice: Undefined variable: post in /home/karnetac/public_html/wp-...
1
vote
2answers
788 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 ...
0
votes
0answers
10 views

My edits are not saved

Everything used to be fine, but now for some reason I’m editing the record, but the old content remains, the new one for some reason does not appear. For example, I have everything stored in the pages ...
0
votes
1answer
649 views

add css to only body text

In my single wordpress posts I want to apply a padding of 100px to the left and right. The problem is that when I apply it to .single .post-content the images also get a padding. However, I want all ...
1
vote
1answer
619 views

Execute Closing Shortcode After the_content

I need to execute a short code on thousands of posts which don't already contain the short code as i've added some manually. I'm using another function to add the opening short code after the 2nd ...
0
votes
1answer
1k views

Remove External Links from WordPress posts Using add_filter() in Theme functions.php

We have been searching high an low for a plugin, code sample or example of how to remove all external links at the theme filter level but can't seem to find anything online. We want to keep the ...
0
votes
1answer
19 views

How to bind each “the_content” elements to a custom variables

I'm implementing bootstrap theme into wordpress and i need you'r help. In Wordpress i created a simple page with paragraph and a list of 3 item's. Product list one Product one - Link Product two - ...
0
votes
1answer
27 views

How to use embed_content hook?

From the document of embed_content: Prints additional content after the embed excerpt. But I don't know which content it will print. Does it take any arguments?
0
votes
1answer
10 views

auto link word link in content

i use this code for auto link word in content <?php function link_words($content){ $words=array( 'test1', 'test2', 'test3' ); $links=array( '<a href="/tag/test1/" rel="nofollow"&...
0
votes
1answer
57 views

the_content() printing DOCTYPE, <html> and <body> tags in the middle of page

I'm building a custom Wordpress theme and I've just come across a bizarre issue where the_content() seems to be printing out the page content wrapped in the following: <!DOCTYPE html PUBLIC "-//...
0
votes
1answer
14 views

How to hook code to show after the_content?

I am trying to hook some content AFTER the_content, but no matter how I do it I still get my custom content BEFORE the_content: add_filter( 'the_content', 'ow_add_sctns_to_ctnt' ); function ...
0
votes
1answer
52 views

Don't allow JavaScript in the content area

Is there any way to disable or remove JavaScript in the page/post content area? So if there was any <script> tags it would remove them or ignore them when outputting the_content();
1
vote
1answer
753 views

Can I insert the feature image inside the content, after any paragraph?

I want to display the feature image inside a post text, perhaps after the third or fourth paragraph (or any) into the_content. Searching the site I've found this code, by Amit: add_filter('...
0
votes
1answer
18 views

How to remove a specific word at the beginning of the content and add it to the end of the content

I want to remove any words in the text of posts, before a specific letter (such as :) that comes at the beginning of the text and add that word to the end of the text. for example: » Original text ...
0
votes
3answers
927 views

Include custom fields into the content of a regular page

Here's my setup: Parent "Gallery" page: _regular page, not custom type or anything _ Several "Project" child pages (could be as few as 1, unlimited number): also normal pages Child pages will either ...
0
votes
1answer
22 views

Shortcode conflicts

My plugin provide shortcodes like this: [cfgeo return="city"] - returns city name [cfgeo include="us"]Text only seen in the US country[/cfgeo] - returns this text only from the visitors in the US. ...
6
votes
4answers
50k 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 ...
0
votes
1answer
405 views

Modify Ixion Theme to Include Post Excerpt On Main Page

This most likely has a very simple solution. I am building a blog using the Ixion theme. I really like the layout so far, and I'm almost ready to publish. However, the theme is designed to only ...
0
votes
2answers
605 views

Add Image Before Posts Entry Title

This code adds the image before all titles on the page. How do i add one single image before the posts entry title? function adt_abovetitle($title){ //Return new title if called inside loop ...
0
votes
2answers
438 views

Extremely slow pageload for long post when using the_content?

My WordPress site has quite a few long posts that slow down page loading time exponentially. This only happens when using the post_content, for example, when using the the_content() and ...
0
votes
0answers
23 views

How to wrap pattern-matches from the_content in [wiki]-shortcode tags

I'm working on a function to wrap word-matches* in [wiki]-shortcode tags. I suspect the best method is to use add_filter() on the_content, and parse using RegEx in preg_replace_callback_array(), but ...
0
votes
2answers
62 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 ...
0
votes
1answer
514 views

content-single.php does not display the_content()

In my single.php I have this <?php while ( have_posts() ) : the_post(); get_template_part( 'template-parts/content-single', get_post_type() ); endwhile; And my content-single.php <div ...
0
votes
0answers
34 views

Cannot replace header & footer using “the_content”

It replace everything except header & footer. I've tried different priority for this function but it doesn't seem to work. I think the_content is only for content and not header/footer, but after ...
0
votes
1answer
36 views

Replace an array (with identical values) with another array in the_content

I'm making a plugin where I need to edit the H2 tags in the post content. I've been at it for two days, but my php knowledge is too limited to solve the issue.. What I want to achieve is to return ...
19
votes
3answers
40k 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&...
0
votes
0answers
16 views

How to wrap ALMOST all content in a div for all old content?

Nearly all of my posts have normal content but then ends with a shortcode. So, h2 elements and paragraphs, but then at the end of the post, the shortcode that ends up implementing a div tag with ...
0
votes
0answers
20 views

Wordpress the_content Filter and GET Parameter

i have the following Problem and i have no ideas left. I try to explain: We have some Producttests you need to register for. A Post can be a Producttest, wich is indicated by a checkbox in the ...
2
votes
2answers
190 views

Sanitizing post content for use in an email

I'm sending the content of a custom post type in a plain text email (it's to send competition entries to a panel of judges), so I need to make sure that $post->post_content is correctly sanitized ...
0
votes
1answer
41 views

How to echo a PHP Code After the Content

i wanted to execute a code after the Content of each blog post. I just want it to be on posts and not on pages. I could execute simple html by the method but could not put the following content. ...
0
votes
1answer
27 views

Strip all HTML tags from product content and resave

My client has loaded about 500 products into Woocommerce, but has inadvertently pasted in a stack of extra tags into the product description- divs and spans etc like below: <div class="summary ...
0
votes
0answers
33 views

Filter to APPEND nofollow to rel

I am trying append nofollow to add external links. If a link does not have a rel attribute, rel="nofollow" will be added. If a link already has rel="nofollow" nothing will happen, and if a link has ...
0
votes
0answers
9 views

Apply a different filer and parse the entire document instead of just the_content

Good morning, I'm trying to modify a plugin, to lazy load my images (a3 lazy load). The problem is that this plugin is returning only the images in the content, but for some reason when we created ...
1
vote
1answer
5k views

str_replace function in theme

I am trying to change the color to red on certain words on my site. However the below code changes each word to "array". Can someone tell me what is wrong with my code? function replace_content($...
1
vote
2answers
89 views

Wrap h1-h6 in a div

So, I am using heading tags h1-h6 on my site in various places, what I'd like to do is put a div around those tags using a WP function. Right now I am using some jQuery to get the job done, but I'm ...
0
votes
2answers
61 views

Add HTML code before the title of the Tag page

I want to show an iframe at the top of a specific Tag page, so once I have is_tag('my_tag'), I will add the iframe before the title of the page. I've tried this code to show the iframe before the ...
7
votes
3answers
45k 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?
1
vote
1answer
36 views

Custom Blocks as part of a theme

I'm new to wordpress, but I'm a pretty competent developer. I'm trying to nail down what my client can do to their site. My idea was to create some special 'blocks' for them, which provide the page ...
1
vote
2answers
51 views

Adding HTML to the end of every post with the Block Editor

I'm converting my posts over to use the new Block Editor. In the past I added an icon to the end of every post to act as a signature and marker saying the article is over (like print magazines do). I ...
1
vote
1answer
279 views

Output content to the_content before a plugin does

I'm using a plugin that appends to the_content() at a priority of 100. I want to place some content after the main content but before this plugin outputs. I assumed if I use a priority less than 100 ...
0
votes
2answers
816 views

Content DISAPPEARS when simply adding normal text for ONE POST ONLY

This is the oddest thing I've ever seen on wordpress. Here's my problem: I have a whole ton of text. But the last few lines I have this: < blockquote>[Laughs] I'm doing the exact same thing ...
1
vote
1answer
18 views

How to hide Ads in between posts on AMP? [closed]

I am using the following code to show ads on my posts after Para 4:- add_filter( 'the_content', 'prefix_insert_post_ads' ); function prefix_insert_post_ads( $content ) { $ad_code = My Ad code; ...
1
vote
1answer
63 views

How to call function at the bottom of post using plugin?

I am creating a plugin and need to write a function which will invoke at the bottom of posts. Currently, I have a shortcode created and I'm calling the shortcode at bottom of each post wherever ...
0
votes
0answers
52 views

How to parse any content which was added after the working out filter 'the_content'

How to parse any content which was added after the working out filter 'the_content'? For example I have html structure of the simple page that i was created via Worpdress Admin Dashboard -> Pages -> ...