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
0 votes
4 answers
1k views

Why do images inserted in the post content via the_content() go off the max-width?

I have many containers over the said image itself such as col-md-10 which defines a max-width of 80% or so, this is how I generate my post: <article id="single-post-<?php the_ID(); ?>" <?...
0 votes
3 answers
2k 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
2 answers
1k 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
1 answer
4k 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
3 answers
883 views

how to print the content of pages inside the front end area

i'm new to wordpress and i'm trying to create a website. i need display the content of the pages when corresponding menu items are clicked. my page.php contain <?php while ( have_posts() ) : ...
0 votes
1 answer
1k views

Get featured image from post on RSS feed

I want to add the featured image to my RSS feed. function rss_post_thumbnail($content) { global $post; if(has_post_thumbnail($post->ID)) { $content = '<p>' . ...
1 vote
1 answer
880 views

Styling text and images in the_content()

So I have recently started working on Wordpress and coming from a different programming background, having the logic but not being able to actually code is an issue I have been butting my head on for ...
0 votes
2 answers
885 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 ...
0 votes
2 answers
1k 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 ...
3 votes
1 answer
779 views

Proper use of the_content filtering

This is a bit difficult without posting scads of code, but my question is: What are the benefits of filtering through apply_filters('the_content', 'anything');, and given my example loop, am I ...
1 vote
2 answers
2k 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
1 answer
844 views

How do I display main query posts in random order using add_filter

So I tried two methods to simply display the main query posts in random order - simple. I'm also trying to understand all this better. Using the_content add_filter, with my own instance of WP_Query ...
1 vote
1 answer
729 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
0 answers
18 views

modify the_content() for page to display attachments with own style

I have for display attachmet on page this function $attachments = get_posts( array( 'post_type' => 'attachment', 'posts_per_page' => -1, ...
1 vote
1 answer
1k 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
2 answers
980 views

$content is empty while using DOMDocument

I'm trying to modify the Image Output on my Wordpress-Site to replace src and srcset with their "data-" Equivalent while adding an additional class. Therefor I'm using DOMDocument and filter for imgs. ...
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 ...
0 votes
1 answer
55 views

Are blocks that are converted to patterns no longer filterable through the_content?

I have a block, say, elseloop/this-block, that was turned into a pattern on one page that it was included on. It is always displayed in an odd spot in the layout, so I want to pull it out of the ...
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 ...
0 votes
2 answers
251 views

Find post tags words in post content and link them to tag URLs

I would like to create link of word(s) in post content (word(s) which is used as post tag of current post) to post tag URL. I created this, and it works, but only for one word (last tag) of post. $...
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 ...
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 ...
0 votes
1 answer
20 views

Read page- or post-content across different builder-plugins

I am currently working on a WordPress-plugin to analyse post- and page-content. The plugin contains a php-function that read the post- and page-content across several different builder-plugins (such ...
-1 votes
2 answers
210 views

echo statement repeats

Creating first wp plugin. Using add action init with filter for the_content I noticed that whenever I echo anything it appears twice in the header, and finally once in the body. Why? Or How can I ...
0 votes
1 answer
1k views

Set Microsoft Word links to open in new window/tab

I'm unable to set Word hyperlinks to open in a new window/tab. Basically, I create a Word document and paste its contents to WordPress, and everything is there, links do work, but they don't have "...
0 votes
0 answers
25 views

Why does the_content filter output var_dump, print_r or echo surrounded by quotes?

I'd like to alter the images for a particular page using the_content filter. When debugging or testing elements of the code, I've noticed that the output is surrounded by quotes. For example, print_r( ...
0 votes
1 answer
21 views

Wp private content show me files attachments into post

I'm using that plugin wp private content and it works fine, but (probably for a update) that show me at the final part of the post a box with link to download someting...in each post! Even if the post ...
0 votes
0 answers
175 views

if CPT content is empty then

I need to be able to do something if the content is empty in a CPT. This works for standard WP posts using the following: if($post->post_content=="") { //Do something if there is content is empty ...
0 votes
3 answers
5k views

How to access & display images from a post without textual content ( and vice versa) according to best wordpress practices

Looking to create a customized single.php for my posts. In one column I'd like to display all images added through the add media function (inserted into post). In the next column all other content ...
0 votes
1 answer
290 views

Some CSS classes missing when rendering the page with get_the_content()

I am using get_the_content() to load other pages content on the current page, and I noticed some block CSS classes are missing in the HTML I get. For example, is-layout-flex layout CSS class is ...
1 vote
1 answer
31 views

Limit total tags in the_content

I am using the_content to display content in a custom theme, but I am running into an issue. Right now, I have some JS code that removes the <br> tags and replaces them with </p><p> ...
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
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 ...
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: ...
0 votes
0 answers
22 views

WP: Override/update the_content from database with the publicly echo the_content

I have many hooks that apply to the_content (post content) so I want to override the database with that final version of the_content (the one that loads publicly to the user), so I get rid of all the ...
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: $...
0 votes
0 answers
28 views

Nested ShortCode works inside the_content, but not outside of it

community; I've spent all weekend trying to crack a problem that so far eludes me. On a multisite implementation, I'm using a simple homegrown plugin to include textbits that are the same across ...
-1 votes
2 answers
1k 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 ...
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&...
0 votes
0 answers
181 views

Using str_replace on the_content and the_excerpt, but not working on archive index pages

I am using code like this to replace a string in my posts. function replace_text($text) { $text = str_replace('look-for-this-string', 'replace-with-this-string', $text); $text = str_replace('look-for-...
1 vote
0 answers
46 views

Add Content Column to Custom Post Type backend

I have a basic custom post type: function create_posttype() { register_post_type('guestbook', array( 'labels' => array( 'name' => __('Guestbook Entries'), ...
2 votes
1 answer
6k views

Function to wrap the_content in a div

Whenever I've developing a new theme I always wrap the_content in a div, like so; <div class="entry-content"> <?php the_content();?> </div> Is there a way I can streamline this ...
0 votes
1 answer
534 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
1 answer
85 views

Post and page content not displaying in search results

I am using a content-search.php template part to output my search results. The post/page titles and links to those posts/pages are working correctly, but for some reason the the_content() function is ...
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 ...
-1 votes
1 answer
137 views

Filter post style attribute

Looking for a hook which enables filtering of a class within the post or content so i can add inline CSS using custom fields for posts on the home page. Something like this - add_filter( 'attr_entry', ...
0 votes
2 answers
1k views

Filter content for get_the_content()

I Need to filter content for posts. If the user is not logged in, then the post content should display "please log in....". If he is logged in, then he can see the post content. I wrote the ...
2 votes
1 answer
2k views

How can I extract the URL of a link from a post?

I am pretty new in WordPress and I have the following doubt. I have a page that take some informations from a list of post that belong to a specific category and show these informations into ...
3 votes
6 answers
3k views

How to use wp_rel_nofollow to add nofollow to external links only?

I want to add nofollow attribute to only external links in the content of the post. Internal links should stay follow. So, can I use wp_rel_nofollow() to make only external links nofollow? Or do I ...
0 votes
1 answer
34 views

Add hook after content without formatting

I want to add a table after the_content with a hook, but it's adding <p> tags in certain areas. This is a plugin, I don't want to remove <p> tags from all the_content, just the table I'm ...

1
2 3 4 5
12