pods-framework / pods

The Pods Framework is a Content Development Framework for WordPress - It lets you create and extend content types that can be used for any project. Add fields of various types we've built in, or add your own with custom inputs, you have total control.
https://pods.io/
GNU General Public License v2.0
1.06k stars 265 forks source link

PODS shortcode does not work in a loop item on an Elementor archive page template #7269

Closed jamieburchell closed 3 months ago

jamieburchell commented 4 months ago

Description

These PODS shortcodes do not work when used in an Elementor Loop Grid template where the Loop Grid is added to an Archive template:

[pods field="example_field"]

[pods]{@example_field}[/pods]

They do work when adding the Loop Grid to a non-archive template.

The issue as reported here:

https://github.com/elementor/elementor/issues/24048

It seems that the automatic detection of being in the loop does not work correctly in this context.

Version

3.1.1

Testing Instructions

  1. Create a new POD "Services" and make sure to enable the archive
  2. Add a required number field named "example_field"
  3. Add a few example Services
  4. Create an Elementor Loop Item Template e.g. "Services Loop Item"
  5. Add a Shortcode widget to the Loop Item Template with either of the shortcodes mentioned in the description above
  6. Add a new Archive Template for "Services"
  7. Add a new Loop Grid to the Archive Template, choosing the newly created "Services Loop Item" template and current query as the source
  8. Observe the example_field is not output

Screenshots / Screencast

No response

Possible Workaround

I can workaround the issue by adding my own shortcode which explicitly retrieves the current post from the loop:

add_shortcode( 'custom_shortcode', function() {
   $pods = pods( 'service', get_the_ID() );
   return $pods->display('example_field');
} );

Site Health Information

`
### wp-core ###

version: 6.4.3
site_language: en_GB
user_language: en_GB
timezone: Europe/London
permalink: /%postname%/
https_status: true
multisite: false
user_registration: 0
blog_public: 1
default_comment_status: undefined
environment_type: production
user_count: 3
dotorg_communication: true

### wp-paths-sizes ###

wordpress_path: /var/web/wp
wordpress_size: loading...
uploads_path: /var/web/app/uploads
uploads_size: loading...
themes_path: /var/web/app/themes
themes_size: loading...
plugins_path: /var/web/app/plugins
plugins_size: loading...
database_size: loading...
total_size: loading...

### wp-dropins (2) ###

advanced-cache.php: true
object-cache.php: true

### wp-active-theme ###

name: Hello Elementor (hello-elementor)
version: 3.0.1
author: Elementor Team
author_website: https://elementor.com/?utm_source=wp-themes&utm_campaign=author-uri&utm_medium=wp-dash
parent_theme: none
theme_features: core-block-patterns, widgets-block-editor, menus, post-thumbnails, automatic-feed-links, title-tag, html5, custom-logo, editor-style, align-wide, woocommerce, wc-product-gallery-zoom, wc-product-gallery-lightbox, wc-product-gallery-slider
theme_path: /var/web/app/themes/hello-elementor

### wp-mu-plugins (3) ###

Bedrock Autoloader: version: 1.0.3, author: Roots
Disable status tests: version: 1.0.0, author: Roots
Register Theme Directory: version: 1.0.0, author: Roots

### wp-plugins-active (10) ###

Code Snippets: version: 3.6.3, author: Code Snippets Pro
Converter for Media: version: 5.12.1, author: matt plugins
Dynamic Visibility for Elementor: version: 5.0.10, author: Dynamic.ooo
Elementor: version: 3.19.3, author: Elementor.com (latest version: 3.19.4)
Elementor Pro: version: 3.19.3, author: Elementor.com
Pods - Custom Content Types and Fields: version: 3.1.1, author: Pods Framework Team (latest version: 3.1.4)
Post Types Order: version: 2.1.8, author: Nsp Code
Rank Math SEO: version: 1.0.213, author: Rank Math
W3 Total Cache: version: 2.7.0, author: BoldGrid
Wordfence Security: version: 7.11.3, author: Wordfence

### code-snippets (9) ###

snippet-5: name: Set WordPress email from address, scope: global, modified: 2023-09-04 11:56:23, tags: [filter, action]
snippet-6: name: Remove front-end dashicons, scope: global, modified: 2023-09-04 11:55:59, tags: [action]
snippet-7: name: Prevent RankMath from purging page cache, scope: global, modified: 2023-09-04 11:55:59, tags: [filter]
snippet-8: name: Set font-display to swap, scope: global, modified: 2023-09-04 11:55:59, tags: [filter]
snippet-9: name: Disable category and tag pages, scope: global, modified: 2023-11-09 14:58:23, tags: [action]
snippet-11: name: Add navigation highlights for custom post types, scope: global, modified: 2024-03-01 10:32:08, tags: [filter]
snippet-12: name: Disable global site search, scope: global, modified: 2023-11-09 14:52:29, tags: [action]
snippet-13: name: Disable Skip to Content Link, scope: global, modified: 2023-12-01 17:05:55, tags: [filter]
snippet-15: name: Shortcode for fund size with currency symbol, scope: global, modified: 2024-03-01 12:44:01, tags: [shortcode]

### wp-media ###

image_editor: WP_Image_Editor_Imagick
imagick_module_version: 1692
imagemagick_version: ImageMagick 6.9.12-93 Q16 x86_64 17898 https://legacy.imagemagick.org
imagick_version: 3.7.0
file_uploads: 1
post_max_size: 50M
upload_max_filesize: 40M
max_effective_size: 40 MB
max_file_uploads: 20
imagick_limits: 
    imagick::RESOURCETYPE_AREA: 7 GB
    imagick::RESOURCETYPE_DISK: 9.2233720368548E+18
    imagick::RESOURCETYPE_FILE: 768
    imagick::RESOURCETYPE_MAP: 3 GB
    imagick::RESOURCETYPE_MEMORY: 2 GB
    imagick::RESOURCETYPE_THREAD: 1
    imagick::RESOURCETYPE_TIME: 9.2233720368548E+18
imagemagick_file_formats: 3FR, 3G2, 3GP, AAI, AI, APNG, ART, ARW, AVI, AVIF, AVS, BGR, BGRA, BGRO, BIE, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CR3, CRW, CUR, CUT, DATA, DCM, DCR, DCX, DDS, DFONT, DJVU, DNG, DOT, DPX, DXT1, DXT5, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, EXR, FAX, FILE, FITS, FLV, FRACTAL, FTP, FTS, G3, G4, GIF, GIF87, GRADIENT, GRAY, GRAYA, GROUP4, GV, H, HALD, HDR, HEIC, HEIF, HISTOGRAM, HRZ, HTM, HTML, HTTP, HTTPS, ICB, ICO, ICON, IIQ, INFO, INLINE, IPL, ISOBRL, ISOBRL6, J2C, J2K, JBG, JBIG, JNG, JNX, JP2, JPC, JPE, JPEG, JPG, JPM, JPS, JPT, JSON, K25, KDC, LABEL, M2V, M4V, MAC, MAGICK, MAP, MASK, MAT, MATTE, MEF, MIFF, MKV, MNG, MONO, MOV, MP4, MPC, MPEG, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NRW, NULL, ORF, OTB, OTF, PAL, PALM, PAM, PANGO, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PGX, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, POCKETMOD, PPM, PREVIEW, PS, PS2, PS3, PSB, PSD, PTIF, PWP, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGBA, RGBO, RGF, RLA, RLE, RMF, RW2, SCR, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, SR2, SRF, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TTC, TTF, TXT, UBRL, UBRL6, UIL, UYVY, VDA, VICAR, VID, VIDEO, VIFF, VIPS, VST, WBMP, WEBM, WEBP, WMF, WMV, WMZ, WPG, X, X3F, XBM, XC, XCF, XPM, XPS, XV, XWD, YCbCr, YCbCrA, YUV
gd_version: 2.3.3
gd_formats: GIF, JPEG, PNG, WebP, BMP, AVIF, XPM
ghostscript_version: not available

### wp-server ###

server_architecture: Linux 5.14.0-362.13.1.el9_3.x86_64 x86_64
httpd_software: Apache
php_version: 8.1.27 64bit
php_sapi: fpm-fcgi
max_input_variables: 1000
time_limit: 120
memory_limit: 256M
max_input_time: 60
upload_max_filesize: 40M
php_post_max_size: 50M
curl_version: 7.76.1 OpenSSL/3.0.7
suhosin: false
imagick_availability: true
pretty_permalinks: true
current: 2024-03-01T12:49:22+00:00
utc-time: Friday, 01-Mar-24 12:49:22 UTC
server-time: 2024-03-01T12:49:21+00:00

### wp-database ###

extension: mysqli
server_version: 10.5.22-MariaDB-log
client_version: mysqlnd 8.1.27
max_allowed_packet: 16777216
max_connections: 51

### wp-constants ###

WP_HOME: https://www.example.com
WP_SITEURL: https://www.example.com/wp
WP_CONTENT_DIR: /var/web/app
WP_PLUGIN_DIR: /var/web/app/plugins
WP_MEMORY_LIMIT: 40M
WP_MAX_MEMORY_LIMIT: 256M
WP_DEBUG: false
WP_DEBUG_DISPLAY: false
WP_DEBUG_LOG: false
SCRIPT_DEBUG: false
WP_CACHE: true
CONCATENATE_SCRIPTS: undefined
COMPRESS_SCRIPTS: undefined
COMPRESS_CSS: undefined
WP_ENVIRONMENT_TYPE: production
WP_DEVELOPMENT_MODE: undefined
DB_CHARSET: utf8mb4
DB_COLLATE: undefined

### wp-filesystem ###

wordpress: not writable
wp-content: not writable
uploads: writable
plugins: not writable
themes: not writable
mu-plugins: not writable

### pods ###

pods-version: 3.1.1
pods-server-software: Apache
pods-user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
pods-session-save-path: /var/lib/php/session
pods-session-save-path-exists: Yes
pods-session-save-path-writable: Yes
pods-session-max-lifetime: 1440
pods-opcode-cache-apc: No
pods-opcode-cache-memcached: No
pods-opcode-cache-opcache: Yes
pods-opcode-cache-redis: No
pods-object-cache-apc: No
pods-object-cache-apcu: No
pods-object-cache-memcache: No
pods-object-cache-memcached: Yes
pods-object-cache-redis: No
pods-memory-current-usage: 25.646M / 40M
pods-memory-current-usage-real: 28.000M
pods-network-wide: No
pods-install-location: /var/web/app/plugins/pods/
pods-developer: No
pods-tableless-mode: No
pods-relationship-table-enabled: Yes
pods-relationship-table-status: 17
pods-light-mode: No
pods-strict: No
pods-allow-deprecated: Yes
pods-api-cache: Yes
pods-shortcode-allow-evaluate-tags: No
pods-can-use-sessions: Yes
pods-settings-types_only: Enable [types_only=0]
pods-settings-watch_changed_fields: Disable [watch_changed_fields=0]
pods-settings-metadata_integration: Disable [metadata_integration=0]
pods-settings-metadata_override_get: Disable [metadata_override_get=0]
pods-settings-media_modal_fields: Enable [media_modal_fields=0]
pods-settings-session_auto_start: Disable [session_auto_start=0]
pods-settings-dynamic_features_allow: Enable [dynamic_features_allow=1]
pods-settings-dynamic_features_enabled: Display and Form [dynamic_features_enabled=display,form]
pods-settings-show_access_restricted_messages: Disable [show_access_restricted_messages=0]
pods-settings-show_access_admin_notices: Enable [show_access_admin_notices=1]
pods-settings-dynamic_features_allow_sql_clauses: Restricted [dynamic_features_allow_sql_clauses=simple]
pods-settings-display_callbacks: Restricted [display_callbacks=restricted]
pods-settings-display_callbacks_allowed: esc_attr,esc_html

`

Pods Package

No response

sc0ttkclark commented 3 months ago

I don't have a solution for you at the moment, I did post to the Elementor issue with a note about how we detect the current item in a loop.

I'm going to add another shortcode option to bypass the in_the_loop() check and just get the current post type / ID regardless.

sc0ttkclark commented 3 months ago

In Pods 3.1.5, you'll be able to bypass the loop check by using bypass_detect_loop="1" in the shortcode.

jamieburchell commented 3 months ago

Thank you for adding the workaround. It's just strange that it's necessary only on an archive page.