How to preserve exact formatting when copy pasting from Facebook into WordPress (or elsewhere)?

How can I copy and paste comment threads (and sometimes the original post) from Facebook into WordPress (or elsewhere) and preserve exact formatting? Screenshot? ok, but text etc is better. Both + link would be ideal. When I paste now, the thread/paragraph structure is intact, but the "likes" etc and profile pic thumbnails don't display. I don't need my whole page/site to look like Facebook, just the content of some pasted posts. Ideally a screenshot would be displayed as a …
Category: Web

What's the best way to trim content from WYSIWYG editor?

I have done an excessive amount of googling and haven't found exactly what I need yet. The client uses the editor (WYSIWYG) to create posts. She adds photos, links to external photos, videos, embeds external videos, and all other formatting. But she does not use the tag nor the excerpt field. When I use wp_trim_words() I get mixed results. Posts with local videos leak markup onto the page A couple posts are only images so there isn't any content at …
Category: Web

Disable TinyMCE Table formatting width/height

Hi there I want to disable automatic formatting of table/td/tr widths and heights in WordPress TinyMCE. I create the table, literally type the data in (not copying it from word or anything like that) and it adds in width and heights to my table cells. Then I copy the code into a text editor and remove the widths and heights, then paste it back in and it adds the widths and heights again. Its giving me a headache. The table …
Category: Web

Formatting issues within Divi theme

I have worked on this website for as many years as it has been live, and have edited and relayed out sections of it without ever an issue. Until last year. The site is built on Divi theme. The site has multiple admins for different reasons. I can see that there is a lot of custom code that has been added to the additional CSS panel by another of the sites admins, presumably to force their work to sit how …
Category: Web

How to add custom HTML tags in the visual mode via keyboard only?

Let say I want to insert different inline formatting texts. I can do that by opening the HTML mode, but is there a way to do it directly in the visual mode? For example, if I type span.a in a paragraph block then it will insert <span class="a"></span> in HTML, similarly how the formatting buttons like bold or italic do. Or perhaps at least a hotkey button to apply custom formatting, like Ctrl+B. Is that possible? Or to take it …
Category: Web

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 &lt;p&gt; tag. I want to get rid of that tag (specifically on the single.php version) of those post types. How can I get inside the formatting in a theme and remove the &lt;p&gt; tags, or create any format that I want for the output of this type of post, without affecting posts of a different post format?
Category: Web

Pasting code into pre-formatted text in Visual Editor not working in 3.3.1

Pre-formatted text in the Visual Editor is not behaving like I'm used to. I've got an old installation (3.2.1), and when create pre-formatted text, all the line-breaks and spacing is preserved. In the latest version (3.3.1), the line breaks are interpreted as new paragraphs, and the code is broken across those paragraphs, leading spaces removed. Process: Copy code from text editor. Click on the &quot;New Post&quot; link. Choose &quot;Preformatted&quot; from the format menu. Paste (ctrl-v). 3.2.1 - Correctly formatted code …
Category: Web

WordPress menu>Custom Link: removing my link formatting and adding %20

I am pasting this url: &lt;a href="#" id="event_inquiryToggle"&gt;TEST&lt;/a&gt; into WordPress Custom Link menu item. When I hit save it saves it as such: http://a%20href=#%20id=event_inquiryToggleTEST/a As such it breaks the link. Thoughts on what I need to add to WP to remove such functionality without having to use a third party plugin?
Category: Web

Keep HTML format when switching from Visual to HTML editor

I've been looking around for a solution that will allow me to edit HTML code and have it remain after a switch to the Visual editor and back. I've tried a bunch of things with no luck: the wp-no-format plugin the Raw HTML plugin entering all my HTML on one line If it were just me managing the content, I would disable the Visual editor. But as I have a number of content managers, and pages on which there is …
Category: Web

How to set up VS Code for WP plugin/theme development in 2021?

I'm trying to improve my WP theme and plugin development workflow. VS Code is my editor/IDE of choice and I'm pretty with it in general. However, setting up VS Code with debugging, formatting, linting etc. for PHP, js and (s)css for WP ended up in quite a struggle. There are various good tutorials about how to achieve this, i.e. Linting and Formatting in Visual Studio Code for WordPress Setting Up PHP CodeSniffer in Visual Studio Code Sniffer, Linter, Pretty Printer …
Category: Web

Place page title in header?

Normally, in WordPress, the page title appears in the content area. I'd like to have the page title appear in the header area. It looks like to do that, I'd have to remove it from its current location in the content-page.php and place it in header.php. But content-page.php is called from page.php, which calls the content-page from within a while loop (while ( have_posts() ) : the_post(); ... ) -- so I'd have to move or copy this into the …
Category: Web

How can I change the date format of the revision list?

The date format looks like this &quot;$ datef = _x ('F j, Y @ H: i: s', 'revision date format');&quot; but I want it to be like this &quot;$ datef = _x ('Y-m-d @ H: i: s', 'revision date format');&quot;. I don't want to modify the core of wordpress, is there a way to do it with a hook? This is in wp/wp-includes/post-template.php, the function is called &quot;wp_post_revision_title_expanded&quot;.
Category: Web

Wordpress | Convert #038; to &

I need to pass a variable inside the permalink that takes me to my custom post, and then execute the $_GET of this variable inside an input of my cf7. The only problem Wordpress encodes the &amp; in #038; I tried to decode the special characters but nothing. Browsing the net, I found on another question here on stackoverflow, the possibility of using: html_entity_decode But if I echo in frontend, it works perfectly, but when I click on the link …
Category: Web

Why is wp_kses not keeping style attributes as expected?

I want to keep the style attribute. $str is just an example, here's my code: $allowed_html = array( 'div' =&gt; array( 'title' =&gt; array(), 'class' =&gt; array(), 'style' =&gt; array() ) ); $str = '&lt;div title='Click to continue' style='display:table'&gt;This is a button&lt;/div&gt;'; wp_kses($str, $allowed_html ); $str will actually receive a bunch of html tags and attributes from a post. Then from there i want to strip out all tags and attributes leaving out only divs tags and style and title …
Category: Web

How to do store, retrieve and write attributes in the registerFormatType method in Guttenberg?

I'm trying to add a format that has multiple, independent attributes to a custom &lt;a&gt; tag. The attributes are href= and data-caption= and data-set= while I use custom client side JavaScript to process the data attributes. Here's my shoddy, work in progress code: var el = wp.element.createElement; var components = wp.components; var withSelect = wp.data.withSelect; var ifCondition = wp.compose.ifCondition; var compose = wp.compose.compose; var caption; var setName; wp.richText.registerFormatType( 'test/set-link', { attributes: { url: 'href', caption: 'data-caption', setName: 'data-set', }, title: …
Category: Web

Number format for wp_count_posts()

I'm trying to format my post my total post count in the header of my site. I have the number in there but would like it to format with the commas eg 1,500 not 1500. I know this is probably really basic but I'm still learning.. any help would be much appreciated. Cheers functions.php function wpb_total_posts() { $total = wp_count_posts()-&gt;publish; echo '' . $total; } Header.php &lt;?php wpb_total_posts(); ?&gt;
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.