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
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
58 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 -> ...
0
votes
1answer
811 views

add_filter the_content doesn't work

I just made a plugin with some meta data and such. I need to alter the content when, but my add_filter('the_content') doesn't do anything... Code: public function run() { add_action( '...
2
votes
1answer
38 views

the_content() in single-{post-type}.php problem

I have Custom Post Type "pjesma" (song), and the only way I managed to display the content is like archive-pjesma.php. It works fine: <?php get_header(); global $post; $args = array( 'post_type' =...
0
votes
1answer
24 views

get_post() containing gallery is outputting an unmatched closing div at the end of the content

I have created a custom page with fetches content from various posts using get_post(id). I fetch the posts using this function:- function get_my_post($id){ $get_post = get_post($id); $...
0
votes
1answer
303 views

the_content(); of custom post type treated as an array or object

I created a custom post type in the mu-plugins folder. function wpdocs_codex_book_init() { $labels = array( 'name' => _x( 'Books', 'Post type general name', '...
0
votes
1answer
23 views

Add HTML before a specific div?

I bought the "Woocommere Checkout Add-Ons" Plugin, which adds upsells to the checkout page - but it only allows to place text after the upsell checkbox. So I got the idea to add an image with some ...
0
votes
1answer
183 views

WordPress adding content into different sections

What I'm trying to figure out is how I can get the content of a page displayed different div's. That means if I add two paragraphs in the editor I would like to display the first paragraph in div ...
1
vote
2answers
23 views

Inserting a functions output after the content

So I am trying to add a button at the end of my blog posts, here is the code I have in the plugin so far: <?php /* Plugin Name: etc.... */ function shares_content() { ?> <div class='...
1
vote
1answer
101 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
1answer
248 views

How to count rows of table in the_content()

In fact, every post in custom post type contains just a table that has several different rows. Every row is important, so we want to count them by a function and I think it is possible by counting <...
0
votes
1answer
25 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 "...
1
vote
0answers
181 views

Gutenberg is Adding Additional HTML Tags When Grabbing the Excerpt

I am running into an issue with Gutenberg where I want to display the excerpt of a post, even when the excerpt field isn't filled in. Usually the functionality of WordPress is when the excerpt is ...
0
votes
0answers
178 views

Get post content before rendering

I am currently working on a shortcode function, where I need to access the content of a post, before its rendering. If I do it like this $content = get_the_content( get_the_ID() ); It gives me the ...
0
votes
3answers
1k views

Get URL from shortcode tag

I am running a wordpress site and I need the correct regex syntax to get a URL from some shortcode that is returned inside the_content(). When I use the_content(), it will return something like ...
6
votes
11answers
31k 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
1answer
359 views

Split the_content into two parts

I want to split the content of a post into two parts. The First part is in an <strong>-tag, it is like a excerpt and in the second part i want to display the rest of the content. But I don‘t ...
0
votes
3answers
154 views

Add review box by function at top or bottom of content

Filter add_filter( 'the_content', 'sandy_posts_filter' ); function sandy_posts_filter( $content ) { global $post; $review_box_pos =get_post_meta( $post->ID, '...
0
votes
2answers
35 views

How to replace text in hompage only

I have a wordpress site with the 10 latest posts shown on the homepage. I need to modify some text (because of duplicate content) on homepage but not on post page. I try to modify the following line ...
-2
votes
1answer
27 views

Creating mixture of shortcodes to use in the visual/text editor

I am attempting to make a page on my site that has a mixture of different kinds of content. So I'd like for the first part to just be the_content, but then beneath it calls to posts under specific ...
0
votes
0answers
13 views

Title and date of last post stays on page even after replacing the_content

I'm doing a plugin that generates custom subpages (i.e. it's an app that has nothing to do with WPs posts). I did the rewrite thing (rewrite + query_vars + template_redirect), I generate the content ...
33
votes
10answers
27k 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 ...
1
vote
0answers
16 views

Missing content in Pages only

I have an odd one. One site is missing all content on it's page (but not posts.) If I add a filter on 'the_content', $content is empty. I've tried giving the filter priority of 1, 0 and even ...
0
votes
0answers
28 views

One Content Filter To Rule Them All

I have a plugin that fetches post content, then runs it through a series of custom and native the_content filters and updates the post using ajax. Problem is that I have many other filters also ...
0
votes
0answers
38 views

Specifying image size used in template the_content

I have a template that is used to display all posts. It uses query_posts with a set of $args that I specify. The template uses the_content to output the content of each post (text and images) I want ...
0
votes
2answers
1k views

get the_content by ID and save the result to one array

I try this: <?php function get_ct($id){ $ct = apply_filters('the_content', get_post_field('post_content', $id)); return $ct; } $arr = array('post_content' => get_ct(...
1
vote
1answer
58 views

Differentiate Nested WP_Query from Parent

I'm filtering the_content in order to append a grid of related posts onto a single post with a nested WP_Query and would like to use the same content.php file as I do for my main query. The problem is ...
1
vote
1answer
970 views

How to change the order (priority) of registered filters (or actions) (e.g. for the_content)?

Is there any way to change the order of filters for e.g. the_content before they are applied? What I currently have is the following ideas: /** * Print all filters for some hook. */ function ...
-1
votes
3answers
84 views

Does WP have a hook for the use of wp_trim_words?

I am using bootstrap to layout a simple webpage. I have also add some css (@media (min-width: 1920px) {..}) media queries which I use for different resolutions Now I hope WP has a hook which checks ...
1
vote
0answers
315 views

Show the content that is after the excerpt using child theme

How do I set a value for $stripteaser using the functions.php file in a child theme so that when the_content() is called on post pages only the post exerpt is shown? I have a theme that I am using. ...
0
votes
1answer
450 views

Edit value of the_content() before showing

I have a task that needs to insert ad-tags in the middle of the_content() value. But I got confused because I can't break down the value of the_content(). Is there any way to put some code in the ...
0
votes
2answers
22 views

Getting content from a referenced post

I have the following, which is successfully pulling the title, thumbnail, and custom field data (YouTube link) from a referenced post, but the content displayed is that of the parent: function ...
1
vote
1answer
38 views

Removing the_content() from the page

There is the_content() in one of the template files which, well, prints the content. I get the content with get_the_content() manipulate it and print it. However, I couldn't figure out which action ...
1
vote
0answers
36 views

get post id by $content (so by post content)

So weird, huh? But, not joke --> I try to be very clean of being: I have a subdomain based multisite network. If the users posts to their sites, I get a clone from the current post to my network home. ...
0
votes
1answer
21 views

How do I isolate the reason a wordpress filter is not running?

I have a wordpress filter defined in my theme's single.php: header( 'X-Filter-1: here' ); add_filter( 'the_content', function( $content ) use ( $details ) { header( 'X-Filter-2: here' ); /...
0
votes
2answers
77 views

Is it possible to change the structure of the HTML generated by the_content()? If yes, how? If not, is there a workaround?

Suppose the editor on my admin dashboard creates the following HTML (when I print to the webpage using the_content(): <blockquote>Hello this is the best quote in the world!</blockquote> &...
0
votes
1answer
345 views

Get the_content surrounded by <h1> instead of <p>

I'm looking to use the_content() on a particular page, but I want it to be surrounded with an <h1> instead of a <p>. I've tried doing this: $thisPagesContent = the_content(); echo '<...
1
vote
1answer
101 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 ...
2
votes
2answers
8k views

Remove empty lines (&nbsp;) when author updates their post

Whenever adding an empty line between paragraphs using TinyMCE, the &nbsp; character entity is added. How can I strip the content of all instances of this character whenever an author updates ...
1
vote
2answers
346 views

Why content_arr['extended'] removes paragraph tags?

I am running into a strange issue where content_arr['extended'] or content_arr['main'] is removing the paragraph tags in the output. Any help, or insight into something i am over looking, trying to ...
1
vote
1answer
264 views

Editing <?php the_content('Read more…'); ?>

Is it possible to automatically add for example image before first h2 tag in the_content?
1
vote
2answers
111 views

Save the_content into custom field

Is it possible to save the content (inside the WP WYSIWYG (the_content)) into a custom field? This is what I have so far: add_action('edit_post', 'save_content_to_field'); function ...
0
votes
1answer
2k views

$content = $post->post_content; with formating

I'm trying to get formating but with no luck. My code looks like this global $post; $content = $post->post_content; And to output here <div class="tribe-events-single-event-description tribe-...
2
votes
1answer
2k views

custom post type grid with content in lightbox [closed]

I'm going around every single wordpress plugin and impossible to find something with this featured . . . . I need a grid list of some custom post type - with inline filter. This is fine and tons of ...
-1
votes
2answers
69 views

Single Loop With Dual Content Area

Is there a way to implement a single loop with dual content area. E.g. A single loop having 2 of <?php the_content(); ?> Dinstinguished as shown bellow with video and write-up respectively ...
0
votes
1answer
405 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 ...
4
votes
4answers
8k 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&...
0
votes
1answer
64 views

Insert template-part inside the content

I want to display an image/banner with link, inside the content of the posts of my blog. Neither at the beginning, nor at the end. It should appear somewhere inside the content of the post. I don't ...
0
votes
1answer
78 views

How to split a post and intercalate elements from a loop

What I'm trying to achieve is spreading related posts throughout the content - such as one reccomendation after every 3 paragraphs. As I see it, three things need be done: 1 - Do the loop. What I'm ...
-1
votes
1answer
19 views

Exactly where I have to insert get_next_post_link() in a post?

Currently I'm working on a website, where there are posts and I intend to give the possibility the user to jump to the adjacent posts with a simple link pointing to them. It will be with ...