WordPress Codesnippets

The Easiest Way To Find WordPress Code Solutions

Latest snippets

add submenu

This code creates a new submenu page on a WordPress site. The new page will be accessible through a URL

Read more

add script to header

get_stylesheet_directory_uri() . ‘/js/custom_script.js’, array( ‘jquery’ ) ); } add_action( ‘wp_enqueue_scripts’, ‘my_scripts_method’ ); ?> This code is used to load a

Read more

add redirect

The wp_redirect function allows you to redirect a user to another page on your website. The first parameter is the

Read more

add roles

, otherwise posts are only saved as drafts ‘edit_themes’ => false, // false denies this capability. User can’t edit your

Read more

add route

The code is adding a new route to the WordPress REST API. The route will be myplugin/v1/author/(id), where (id) is

Read more

add registration form

‘ ), ‘label_last_name’ => __( ‘Last Name’ ), ‘label_nickname’ => __( ‘Nickname’ ), ‘label_website’ => __( ‘Website’ ), ‘label_aim’ =>

Read more

add robots.txt

It will also prevent search engine robots from accessing the content of your website. This can be useful if you

Read more

add role

This code snippet creates a new user role with various capabilities. The new role will be able to read, edit

Read more

add query var

This code will add a new query variable to WordPress. The new query variable will be called “my_var”.

Read more

add pdf

The wordpress code above creates a link to a PDF file. When clicked, the PDF will be downloaded.

Read more