Creating a post with guttenberg content using the WP-REST-API - wordpress

I am using the wp rest api for adding posts to my site from another app. Therefore I use POST /wp-json/wp/v2/seminar where seminar is my custom post type. In the post data I set content to some text.
The Problem is that Wordpress creates a block with the tinyMce editor instead of using the default guttenberg paragraph block (see images below).
What is created:
Image of Tinymce
What I want to be created:
Image of paragraph editor
Does someone know a way to make wordpress creating the paragraph insted of the tinymce block?

Try to make content like this
<!-- wp:paragraph -->
<p>my content text</p>
<!-- /wp:paragraph -->

Related

Post Featured Image block not being rendered when post content is fetched directly

I'm maintaining a custom REST endpoint for a WordPress site to which they've just added a new custom post type. The REST response has a content object which simply contains all of the post's content:
$magData->content = apply_filters('the_content', get_post_field('post_content', $magID));
However, while regular image blocks and even custom blocks (created with ACF) are output in this content object with no issue, it looks like the core Post Featured Image Block isn't rendering at all:
As you can see, it simply renders a bunch of line breaks (\n\n\n\n) instead of the expected <figure> element. I would expect any Gutenberg Block elements to be rendered once the the_content filter is applied to it, but it doesn't look like that's working for this specific block.
For reference, here's what the block looks like in Gutenberg - it just uses the post's own Featured Image for its image content:
Looking at the post's post_content in the database, the Post Featured Image block is simply a self-closing comment block: <!-- wp:post-featured-image /--> - and in the actual page source, it gets rendered as:
<figure class="wp-block-post-featured-image"><img loading="lazy" width="1280" height="853" src="https://example.com/wp-content/uploads/2022/05/field.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" srcset="{some_image_sizes}" /></figure>
So I'm left scratching my head as to why a Post Featured Image Block would render just fine in the actual WP front end, but not when called using apply_filters('the_content', $content).

Set custom initial page in blogdown

Is it possible to set the initial page in blogdown? Instead of the default one that shows the posts I would like to have a custom one. I want to have my own index.html (the root one).
Thanks.
Assuming you are using Lithium - A simple responsive Hugo theme, one possible way to do this is the following.
1] Copy layouts/_default/list.html to a new layout file named layouts/_default/home.html
2] Edit layouts/_default/home.html so it contains this:
{{ partial "header.html" . }}
<main class="content" role="main">
<h1>
My heading
</h1>
<p>
My paragraph
</p>
</main>
{{ partial "footer.html" . }}
Your home page will now contain "My heading" and "My paragraph," along with the Lithium header and footer. If you do not want to use the Lithium header and/or footer, remove those partial calls from home.html.[*] There's a lot more that you can do with Hugo layout files, which you can learn about in my Hugo tutorial in the section 15. Explore the layouts directory and at gohugo.io's Category: templates.
I hope this is enough to get you started with Hugo layout files.
[*] If you remove the header partial, you need to put something like <!doctype html><title>a</title> at the top. More about this is in What's a valid HTML5 document? - Stack Overflow

How to display HTML content without Gutenberg blocks in Wordpress?

My developer has updated my Wordpress to the latest and with it comes Gutenberg. I'm not a fan and I see every one of my HTML paragraphs now looks like this:
<!-- wp:paragraph -->
<p>Hello world!</p>
<!-- /wp:paragraph -->
Needless to say, the <!-- wp:paragraph --> is confusing to me, especially because I write my content in HTML. It has the block tags around everything, including images. I don't want to deal with these.
I tried using this plugin to disable Gutenberg entirely: https://wordpress.org/plugins/classic-editor/ but the Gutenberg paragraph tags remain. How can I revert my HTML content back to how it was before this awful Gutenberg update?

Wordpress - Remove auto tags from field content in custom posts type

NOTE: Previous questions on this subject only relate to content entered into the main Wordpress editor window - NOT custom fields in the admin area. The accepted answers do not answer this question.
This question is specific to removing surplus <p> and <br /> tags within custom fields.
Using Wordpress I know it's pretty simple to remove the <br/> and <p> tags from the content entered in the editor:
remove_filter('the_content', 'wpautop');
However, while this deals with content entered in the main post info window, this isn't being applied to markup entered in a 'Types' custom field in a custom post type. There, when content is pasted in, it still gets the auto <p> and <br /> tags.
I can work around this temporarily by altering the core includes/formatting.php file:
function wpautop($pee, $br = 0) {
However, this will get overwritten on future Wordpress upgrades. How can I remove auto <p> and <br/> tags from any content entered in the Wordpress admin area - specifically custom field areas where the remove_filter on the_content has no effect?

Remove content after <!--more--> tag

I'm trying to show at the category page only the content of the post that is before the <!--more--> tag. I'm using the latest Wordpress version.
In other words the structure will go like this
Content
<!--more-->
Content I want to be removed and only shown if the single post is displayed.
I've already got rid of the "Read More" link, and I've already tryed to use CSS and display:none; but none of those works fine
The code generated by wordpress is the following
<h2 class="entry-title">Post Name</h2>
<div id="chan" class="blanco">Content Shown</div>
<p><span id="more-50"></span>Post description.</p>
At the index.php I've managed to make it work since it shows the link and not the content itself, however in the page.php doesn't work.
Thank you very much in advance!
<?php the_content(); ?> will output the content, trimmed to just before the <!-- more --> tag, if the tag is used.
From the codex:
If the quicktag <!--more--> is used in a post to designate the "cut-off" point for the post to be excerpted, the_content() tag will only show the excerpt up to the <!--more--> quicktag point on non-single/non-permalink post pages.

Resources