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
0
votes
1answer
23 views

Highly stylized pages

I'm building my own WP site, with its theme from scratch, and I need 2 very customized pages, including the front page. To give you an idea, a bit like this. (mine will be more simple though) That ...
0
votes
1answer
34 views

Omit image captions from get_the_content()

I use a theme that calls get_the_content() to display short excerpts of the latest blog posts on the home page. Now I noticed that the excerpt sometimes starts with an image caption, if the blog post ...
0
votes
1answer
32 views

How to get different html tags from the content using regex?

I am trying to get different html tags from a single post and display them as nested accordion. I have quite accomplished. the only problem I have is that. When I try to show all the p tags content ...
0
votes
3answers
976 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
0answers
41 views

How to make the_content() function to display only the text inside a specific paragraph targeting its class? [duplicate]

this is the content of a single post: Dec 4, 2015, First paragraph Feb 3, 2016, Second paragraph Feb 3, 2017, Third paragraph I am currently using a plugin named PHP Code which allows to ...
0
votes
0answers
11 views

Post content is escaped when visual editor is turned off

When visual editor is turned off, then $post->post_content is escaped. With visual editor turned on, the exact post content is obtained as saved. When visual editor is ON, output of $post->...
0
votes
2answers
632 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
1answer
1k views

Problem in replacing the_content with the_excerpt()

I want to add read more to a blog. For that I need to replace the function the_content(). I found it in the loop file and replaced it with the_excerpt() but still posts are being shown of full length. ...
0
votes
1answer
478 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
2answers
3k 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
votes
3answers
5k views

How add class the_content();?

How do I add a class the_content();? <div class="csoporszoveg"> <h3 class="csoporcim"><?php if ($settings['enable_link']) { echo '<a href="' . get_permalink($...
0
votes
1answer
544 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 ...
1
vote
2answers
837 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
0
votes
1answer
32 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 ...
1
vote
1answer
49 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
32 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
685 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
25 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
843 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
661 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
625 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
20 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
28 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
13 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
99 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
22 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
57 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
776 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
19 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
1answer
24 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
52k 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
410 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
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
223 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
0answers
36 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
61 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 ...
20
votes
3answers
42k 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
17 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
206 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
61 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
39 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
35 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
10 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
138 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
66 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
47k 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?