Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

add_action('init',
function() {
unregister_block_type('core/latest-posts');
register_block_type(
'core/latest-posts',
array(
'attributes' => array(
'categories' => array(
'type' => 'string',
),
@websupporter
websupporter / upload-a-file.MD
Created June 15, 2017 14:34
Upload a file using the WordPress REST API

Upload files

Using the REST API to upload a file to WordPress is quite simple. All you need is to send the file in a POST-Request to the wp/v2/media route.

There are two ways of sending a file. The first method simply sends the file in the body of the request. The following PHP script shows the basic principle:

<?php
/**
* Plugin Name: Deactivate WordPress
* Author: David Remer
* Description: Do use with care. Actually: Do not use!
**/
function deactivate_wordpress() {
remove_action( 'all', 'deactivate_wordpress' );
<!doctype html>
<html>
<head>
<title>Deaktiviert</title>
</head>
<body>
<p>Diese Seite wurde deaktivert.</p>
</body>
</html>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteRule . /index.html [L]
</IfModule>
# END WordPress
<?php
$upgrading = time();
<?php
function wpcodex_hide_email_shortcode( $atts , $content = null ) {
if ( ! is_email( $content ) ) {
return;
}
return '<a href="mailto:' . antispambot( $content ) . '">' . antispambot( $content ) . '</a>';
}
add_shortcode( 'email', 'wpcodex_hide_email_shortcode' );
<?php
echo antispambot( 'max.mustermann@example.com' );
// Real output: &#109;ax.&#109;&#117;s&#116;erma&#110;&#110;&#64;&#101;&#120;a&#109;&#112;le&#46;&#99;om
?>
<?php
add_action( 'after_setup_theme', 'theme_start_content' );
function theme_starter_content() {
add_theme_support( 'starter-content', array(
'posts' => array(
'home',
'test' => array(
'post_type' => 'page',
<?php
add_action( 'after_setup_theme', 'theme_start_content' );
function theme_starter_content() {
add_theme_support( 'starter-content', array(
'posts' => array(
'home',
'test' => array(
'post_type' => 'page',