the_content() behavior on attachment.php versus single.php

This is correct behavior, if your attachment doesn’t actually have anything in post_content field (which is quite common). When post–centric templates run, prepend_attachment() is used as filter to “emulate” post content. This is not the case with template “intended” for attachments. If you look at template-loader.php: elseif ( is_attachment() && $template = get_attachment_template() ) : … Read more

Change Content for Specific Page

Your function is signup but you’re hooking check_for_signup. You’re also trying to apply the_content filters from within a function that’s hooked to the_content: function wpse_225562_replace_for_signup( $content ) { if ( strcmp( ‘signup_slug’, get_post_field( ‘post_name’ ) ) === 0 ) { $content=”Sign up, bitch.”; } return $content; } add_filter( ‘the_content’, ‘wpse_225562_replace_for_signup’ ); Here we are simply … Read more

Content editor creating blank paragraphs in spaces and creating &nbsp in the_excerpt

Judging from your site’s content and the comments, you may try using the following CODE in your theme’s functions.php file. It’ll remove empty <p>&nbsp;</p> tags from post content: add_filter( ‘the_content’, ‘wpse_257854_remove_empty_p’, PHP_INT_MAX ); add_filter( ‘the_excerpt’, ‘wpse_257854_remove_empty_p’, PHP_INT_MAX ); function wpse_257854_remove_empty_p( $content ) { return str_ireplace( ‘<p>&nbsp;</p>’, ”, $content ); } However, after it removes the … Read more

Filter Gutenberg Blocks Content

Have you tried using parse_blocks() (pass in get_the_content())? That returns an array of all the blocks in your content. From there you can pull out block names and id attributes using an array map or foreach. Assuming you only want to pull anchor tags from the headings, you could do something like: $blocks = parse_blocks( … Read more

What functions are included in apply_filter(‘the_content’)

You can use the global $wp_filter array to check for callbacks on each filter. Here is for example a code snippet that prints out all the callbacks on the the_content filter in the footer part of your theme: add_action(‘wp_footer’,function(){ global $wp_filter; printf(‘<pre>%s</pre>’,print_r( $wp_filter[‘the_content’],true)); }); The priority 10 part could look like this: [10] => Array … Read more

Function to wrap the_content in a div

You can hook the_content filter. paste below code in functions.php : <?php add_action(‘the_content’,’ravs_content_div’); function ravs_content_div( $content ){ return ‘<div class=”entry-content”>’.$content.'</div>’; } ?> After paste this code in functions.php, the_content() print post/page content after wrap content in div with class entry-content.

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

Exist some WordPress function that retrieve the list of links (in my specific case only one) that are into a post? Check out the core wp_extract_urls() function: $urls = wp_extract_urls( $content ); that will extract urls from any given content. Example $content=”Two test sites: <a href=”http://foo.tld”>Foo.tld</a> and https://bar.tld”; $urls = wp_extract_urls( $content ); print_r( $urls … Read more

How I can split text in the_content() into 2 columns?

Did you try css? <div class=”columncontent”> <?php the_content(); ?> </div> Then the css: .columncontent { column-count: 2; } Depending on your theme, you could just find a div already surrounding your content too. There is all sorts of magic there! https://www.w3schools.com/css/css3_multiple_columns.asp The only thing I would suggest is that you use media queries, as the … Read more

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

First of all, you shouldn’t use get_posts on your CPT archive – WP already creates a query and selects posts that should be display in there. So your archive-pjesma.php should look like this: <?php get_header(); ?> <?php while ( have_posts() ) : the_post(); ?> <h2><a href=”https://wordpress.stackexchange.com/questions/326484/<?php the_permalink(); ?>”><?php the_title(); ?></a></h2> <?php // the_content(); ?> <?php … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)