Simple task, but it isn't working: <?php $content = apply_filters( 'the_content', get_the_content() ); $contentWithoutHTML = wp_strip_all_tags($content); $pos = strpos($contentWithoutHTML, " ", 100); $contentFinal = substr($contentWithoutHTML,0,$pos ); echo $contentFinal . "..."; ?> My post is way over 100 characters long (with spaces), and yet I get strpos(): Offset not contained in string error, which leads me to believe it isn't actually pulling the entire content string. But I applied filters like I believe I should... please assist. Also sometimes even if …
So, basically, I want to remove trailing slashes from specific domain urls. For example: https://www.example.com/here/postname/ into https://www.example.com/here/postname I have 10.4.21-MariaDB which should support REGEXP_REPLACE function. This is my query: UPDATE wp_posts SET post_content = REGEXP_REPLACE(post_content, '(http\S+)\/(\s|$)', '$1'); or this one more specifically: UPDATE wp_posts SET post_content = REGEXP_REPLACE(post_content, '(https:\/\/www\.example\.com\/here\/\S+)\/(\s|$)', '$1'); which according to regular expressions should work: https://regex101.com/r/slLbgg/1 What am I doing wrong? Any kind of help is appreciated! :) This is the result:
I am trying to create some kind of repeated fields and for that, I want to create a new wp editor with some unique ID. So my question is there any way to create wp_editor using any js? same as we get using <?php wp_editor() ?> WordPress function. I have tried using tinyMCE .init( { mode : "exact" , elements : "accordion_icon_description_"+response.success.item_count }); but it prints very basic editor which is I think not same as of WordPress post content …
How do I order a post query by the length of the post content? $orderby = ?; $query = array( 'posts_per_page' => 10, 'post_status' => 'publish', 'orderby' => $orderby, 'order' => 'DESC', ); $the_query = new WP_Query($query);
I'm migrating from one Visual Page editor to another. I'm extracting the texts surrounded by the shortcode opening and closing tags. Before I write my own parsing script, I wanted to make sure that Wordpress didn't already have a solution for this, or something else didn't already exist either. I feel like this is a common need that there may already be something to handle it. Here is an example of the post_content data. As you can see this can …
Gutenberg is still relative new concept, so I lack experiences (and the Internet lacks good tutorials). My goal it to wrap all heading titles generated by Gutenberg's "Heading" block with the <span> tag. So instead following code <h2>Tips and trics</h2> it renders this way <h2><span>Tips and trics</span></h2> How to start? It's JS or PHP job? Is there any filter family? What documentation search for on Wordpress.org?
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 of the images on the posts pages to be set to 100%. Is there a way to separate the actual body text and the images? This seems like a fairly simple question. But I can't figure it out. Any help is …
I have a form, with multiple inputs that I am trying to get posted to the wordpress "post_content". I am able to get the title field and only one other field to post successfully, only when making a field name "description" instead of "description[]", but have no idea how I can get the rest to submit into the post_content. I would like the inputs posted like the image I have created below. Here is the code I currently have that …
I've made a flexible content section in ACF for a specific category that allows the user to post text and different image galleries onto their post. This all works perfectly whilst I'm on my localhost but now I've uploaded the site none of the content is showing. My code is quite messy but the code in my single.php is below and this is the link to a live post https://www.exoticsoftware.co.uk/2021/12/01/pendas-fen/, the only things that show on the page are the …
I am basically trying to duplicate wordpress pages using the Wordpress API. I do get the page content using "GET /wp/v2/pages/" endpoint. I receive the the JSON data which includes: "content": "<style>/*! elementor - v3.5.5 - 03-02-2022 */\n.elementor-heading-title{padding:0;margin:0;line-height:1}.elementor-widget-heading .elementor-heading-title[class*=elementor-size-]>a{color:inherit;font-size:inherit;line-height:inherit}.elementor-widget-heading .elementor-heading-title.elementor-size-small{font-size:15px}.elementor-widget-heading .elementor-heading-title.elementor-size-medium{font-size:19px}.elementor-widget-heading .elementor-heading-title.elementor-size-large{font-size:29px}.elementor-widget-heading .elementor-heading-title.elementor-size-xl{font-size:39px}.elementor-widget-heading .elementor-heading-title.elementor-size-xxl{font-size:59px}</style><h3>Abi '22 me But when I use this content to send a request to "POST /wp/v2/pages" endpoint including the same content it looks really crappy. As you can see, I use elementor. Is that the reason it …
Background: I am using WordPress posts for Newsletter. I am importing the posts through an api and use them in a Newsletter tool to send them out. I am downsizing the featured image before feeding to the Newsletter tool. But now I am facing some troubles, sometimes I have High resolution post content images. Issue: I need to resize those inner images of post content but without using any css and html image tags attributes as I am using them …
I have this code to display the content of a specific post outside the loop (actually in the archive.php template file). How do I include the tags? <?php $my_id = 1576; $post_id_1576= get_post($my_id); $content = $post_id_1576->post_content; $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); echo $content; ?>
I want to be able to get post_content with line breaks. What is the best way to do it? I previously use the_content() which was working fine until I needed to install a plugin that adds share buttons on each post. Since then the output of my the_content includes texts from the share buttons. I tried to use post_contents which contains the correct content I need to output on my template file but the problem is the line breaks were …
Today a member of our content team reported that when they attempted to save a post in block editor mode, they continually received an error. Updating failed. The response is not a valid JSON response. After some debugging steps we determined that the string "cmd.exe" was to blame. When that string was present the author always got the above error. But when the string was gone or had a space after the ".", the post saved and displayed just fine. …
i'm working in android application that use wordpress rest api to get blog from website to , i don't have any knowledge about php or wordpress , but i take some time to learn about it , any way my problem is on the json .the content contain paragraphs unknown and i don't know how to solve this problem ,please help
I have 8 sites in my multi-site network: Group Landing site (domain) Group 1 site (subdomain 1) Group 2 site (subdomain 2) Group 3 site (subdomain 3) Group 4 site (subdomain 4) Group 5 site (subdomain 5) Group 6 site (subdomain 6) Group 7 site (subdomain 7) Essentially, Groups 1 to 7 will have separate contents. However, the Group Landing site will have content from both. I would rather not have the user enter the content twice. The post must …
I would like to code a plugin that injects the custom content to any type of post (post, page, product, any others) but I would like to allow the users to let them select the place of content too. Such as; before/after the title, before/after the content, before/after the comment section, and all other possibilities (e.g. the_content_more_link filter etc). As you know, there are many plugins, themes, custom post type plugins that they create their own custom filter hooks (e.g. …
I tried adding a filter at the content etc but that one just gives access to content stored in wp_posts. I am interested in getting the rendered html with meta tags etc for a post, after it is updated. How can I do this? I can do, but it does not look like the best option to me as the blog might have a paywall and this code would fail. What else is available? add_action( 'save_post', 'my_save_post_function', 10, 3 ); …
I noticed that internal links to other posts have data- * Attribute. One of Post ID. And the other of Post Type. (As in screenshot). The problem is, it's only in the block editor (Gutenberg). And not in the classic editor. The question is, is it possible to add this data, even in the classic editor. Thank you. I want, When the mouse goes over a link. An AJAX request will be made, with the post ID data. Then WordPress …