• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Genesis Theme Framework a2z

Genesis Theme Framework a2z

WordPress Dynamic API Reference

  • Home
  • Plugins
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / set_singular_images() – Update singular image state to turn featured image output on or off for the provided post types.

You appear to be a bot. Output may be restricted

Description

Update singular image state to turn featured image output on or off for the provided post types.

Expects to receive a JSON object with post type as key, then 1 for the value to enable images, and 0 to disable. {

  • "pages": 0, // Disable featured images on pages.
  • "posts": 1 // Enable featured images on posts.
  • }

Returns an array of all post types that now have featured images enabled after the update is applied. For the above example, assuming no other post types have genesis-singular-images support: [ "posts" ]

Usage

set_singular_images();

Parameters

Returns

void

Source

File name: genesis/lib/functions/rest.php
Lines:

1 to 25 of 25
function set_singular_images() {
  \register_rest_route(
    'genesis/v1',
    '/singular-images',
    [
      'methods'             => 'PUT',
      'callback'            => function( $request ) {
        $post_types = $request->get_json_params();

        foreach ( $post_types as $type => $value ) {
          $genesis_options = get_option( GENESIS_SETTINGS_FIELD );

          $genesis_options[ "show_featured_image_{$type}" ] = $value;
          update_option( GENESIS_SETTINGS_FIELD, $genesis_options );
        }

        return \genesis_post_types_with_singular_images_enabled();

      },
      'permission_callback' => function() {
        return current_user_can( 'edit_theme_options' );
      },
    ]
  );
}
 

Published: 25th November 2019 | Last updated: 25th November 2019

Primary Sidebar

Information

Function name: set_singular_images
Plugin ref: Genesis Framework
Version: 3.3.5
Sourcefile: lib/functions/rest.php
File ref: lib/functions/rest.php
Deprecated?: No
API Letters: I,S

Footer

Genesis a2z
Genesis Theme Framework a2z
WordPress Dynamic API Reference
WordPress 5.9.3
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  genesis.wp-a2z.org
© Copyright Genesis a2z 2014-2022. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites