Custom Data

Besides a plethora of options, SleekPixel allows you to add custom entries to the dynamic data dropdown in the editor. This can be achieved using the sleekPixel/data/custom filter.

functions.php
add_filter(
  "sleekPixel/data/custom", function ($data, $args) {
    $postId = $args["postId"];

    // Add custom data entry 1
    $data[] = [
      "value" => "customData1",
      "label" => "Custom data",
      "data" => get_field('my_field', $postId),
    ];

    // Add custom data entry 2
    $data[] = [
      "value" => "customData2",
      "label" => "Custom data 2",
      "data" => "My custom title #2",
    ];

    return $data;
  }, 10, 2 );
Copy

× Close

Menu

× Close

Search

  • /custom-data
  • /general
    • #key-features
    • #how-it-works
    • #processing-options
    • #integration-methods
  • /hooks
    • php
        #conditions
        #data
        #data-custom
        #image-element-data
  • /i18n
    • #example-adding-wpml-translated-post-titles
  • /info
    • how-text-works
        #text-box-controls
        #dynamic-text-behavior
        #vertical-alignment
        #best-practices-for-text-design
    • rendering-differences
        #understanding-the-two-rendering-engines
        #best-practices-for-optimal-results
        #reporting-and-resolving-differences
  • /locations
    • #output-types
    • #open-graph
    • #twitter-card
    • #open-graph--twitter-card
    • #featured-image
    • #conditions-and-values
    • #values
    • #conditions
  • /rendering
    • function
        #get_image_url
        #parameters
        #usage
        #get_image
        #parameters-1
        #usage-1
        #render_image
        #parameters-2
        #usage-2
    • shortcode
        #basic-usage
        #parameters
        #advanced-usage
        #using-in-templates
  • /settings
    • api-keys
        #google-fonts-api-key
        #obtain-a-google-fonts-api-key
        #enter-the-api-key-in-sleekpixel-settings
    • custom-fonts
        #uploading-custom-fonts
        #managing-custom-fonts
        #using-custom-fonts-in-the-editor
    • options
        #file-format
        #image-processing
        #understanding-image-processing-modes
        #configure-image-processing-mode-in-sleekpixel
        #considerations
× Close

Navigation

× Close

Search

  • /custom-data
  • /general
    • #key-features
    • #how-it-works
    • #processing-options
    • #integration-methods
  • /hooks
    • php
        #conditions
        #data
        #data-custom
        #image-element-data
  • /i18n
    • #example-adding-wpml-translated-post-titles
  • /info
    • how-text-works
        #text-box-controls
        #dynamic-text-behavior
        #vertical-alignment
        #best-practices-for-text-design
    • rendering-differences
        #understanding-the-two-rendering-engines
        #best-practices-for-optimal-results
        #reporting-and-resolving-differences
  • /locations
    • #output-types
    • #open-graph
    • #twitter-card
    • #open-graph--twitter-card
    • #featured-image
    • #conditions-and-values
    • #values
    • #conditions
  • /rendering
    • function
        #get_image_url
        #parameters
        #usage
        #get_image
        #parameters-1
        #usage-1
        #render_image
        #parameters-2
        #usage-2
    • shortcode
        #basic-usage
        #parameters
        #advanced-usage
        #using-in-templates
  • /settings
    • api-keys
        #google-fonts-api-key
        #obtain-a-google-fonts-api-key
        #enter-the-api-key-in-sleekpixel-settings
    • custom-fonts
        #uploading-custom-fonts
        #managing-custom-fonts
        #using-custom-fonts-in-the-editor
    • options
        #file-format
        #image-processing
        #understanding-image-processing-modes
        #configure-image-processing-mode-in-sleekpixel
        #considerations