Custom Shortcodes on Archive Page not rendering #6651
Unanswered
thomasavvion
asked this question in
Q&A
Replies: 2 comments
-
Issue Label Bot is not confident enough to auto-label this issue. See dashboard for more details. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hello @thomasavvion, I believe echo do_shortcode(
pods( $post->post_type, $post->ID )->template( 'template_' . $post->post_type . '_list' )
); More info: https://developer.wordpress.org/reference/functions/do_shortcode/ Let me know if this helps! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Issue Overview
Custom shortcodes that work fine on pages / post types and inside pods templates - are not rendered on the archive page.
Expected Behavior
I have defined custom shortcodes in my functions.php that render the pods field labels in the frontend.
I want to use these custom shortcodes not only in pods templates and inside custom post types, but also on my customized archive.php.
Current Behavior
Points 1-4 below illustrate what I have done and what the results are
`/*
*/
function pods_get_field_label($atts) {
//if($ct === false || $label === false)
$tmp = explode('_', $atts['field']);
$ct = false;
if(is_array($tmp)) {
$ct = $tmp[1];
}
return $ct->fields( $atts['field'], 'label' );
}
add_shortcode( 'get_field_label', 'pods_get_field_label' );
/*
*/
function pods_get_image($atts) {
$mypod = pods( 'post_type_project', $atts['pods_id'] );
$mypod_image = $mypod->field('field_project_image_teaser');
$rand_size = array('project-teaser-large', 'project-teaser-small');
$rand_num = rand(0,1);
$size = wp_get_attachment_image_src($mypod_image['ID'], $rand_size[$rand_num]);
//return '
return '
}
add_shortcode( 'get_pods_image', 'pods_get_image' );`
<a href="{@permalink,esc_url}" class="custom-template project-list-item {@taxonomy_project_category}"> [if field_project_image_teaser][get_pods_image pods_id="{@ID}"][/if] <div class="project-list-text"> [if field_project_name]<div class="field-project-name">{@field_project_name}</div>[/if] [if taxonomy_project_series]<div class="taxonomy-project-series">[get_field_label field="taxonomy_project_series"]: {@taxonomy_project_series}</div>[/if] [if field_project_client]<div class="field-project-client">[get_field_label field="field_project_client"]: {@field_project_client}</div>[/if] [if taxonomy_project_category]<div class="taxonomy-project-category">[get_field_label field="taxonomy_project_category"]: {@taxonomy_project_category}</div>[/if] [if field_project_date]<div class="field-project-date">[get_field_label field="field_project_date"]: {@field_project_date}</div>[/if] [if field_project_description]<div class="field-project-description">{@field}{@field_project_description}</div>[/if] </div> </a>
[pods name="post_type_project" template="template_post_type_project_list"]
<?php echo pods($post->post_type,$post->ID)->template('template_'.$post->post_type.'_list'); ?>
.... renders the custom shortcodes from 1) in plain text in the front end, ie [get_field_label field="field_project_client"] etc. Note: The content itself is rendered correctly.
Steps to Reproduce (for bugs)
Simply reproduce steps 1-4 above.
WordPress Environment
Debug Information
WordPress Version: 5.1.1
PHP Version: 5.6.40-0+deb8u1
MySQL Version: 5.5.62
Server Software: Apache
Your User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
Session Save Path: /var/lib/php5/sessions
Session Save Path Exists: Yes
Session Save Path Writeable: Yes
Session Max Lifetime: 1440
Opcode Cache:
Apc: No
Memcached: No
OPcache: Yes
Redis: No
Object Cache:
APC: No
APCu: No
Memcache: No
Memcached: No
Redis: No
WPDB Prefix: wp_
WP Multisite Mode: No
WP Memory Limit: 40M
Current Memory Usage: 44,343M
Current Memory Usage (real): 45,500M
Pods Network-Wide Activated: No
Pods Install Location: /var/www/batou/binnerKatrin/www/dev/binka_www_wp/wp-content/plugins/pods/
Pods Tableless Mode Activated: No
Pods Light Mode Activated: No
Currently Active Theme: BergerSchmidt
Currently Active Plugins:
Pods - Custom Content Types and Fields: 2.7.12
Search & Filter: 1.2.11
Beta Was this translation helpful? Give feedback.
All reactions