-
AuthorPosts
-
February 27, 2019 at 11:28 am #1072243
Trying to customize a content filter for a post format
But I can’t use $current_post[‘the_id’] defined in loop-index.php
I get a notice saying “Undefined index: the_id ”
If I try to use get_the_ID() it only returns 1’sWhat should I use?
March 1, 2019 at 3:21 pm #1073228any help?
March 1, 2019 at 6:31 pm #1073326Hi pharefm,
Can you share your code with us?
Best regards,
VictoriaMarch 1, 2019 at 6:44 pm #1073338if(!function_exists('avia_audio_content_filter')) { function avia_audio_content_filter($current_post) { $match_audio = get_post_meta(get_the_ID(), 'audio_file', false); if (!empty($match_audio)) { $current_post['before_content'] = do_shortcode('[audio src="'.$match_audio[0].'"][/audio]'); $current_post['content'] = str_replace($match_audio[0], "", $current_post['content']); } return avia_default_title_filter($current_post); } }
March 4, 2019 at 9:58 am #1074252Hi pharefm,
Please post us your login credentials (in the “private data” field), so we can take a look at your backend.
- Install and activate ” Temporary Login Without Password “.
- Go to ” Users > Temporary Logins ” on the left-side menu.
- Click ” Create New “.
- Add the email address for the account ( you can use (Email address hidden if logged out) ), as well as the ” Role ” making that the highest possible and the expiry about four days
( do be sure that we have enough time to debug ). - Click ” Submit “.
- You’ll now have a temporary account. Please provide us here in the private section the URL, so we can login and help you out.
When your issue is fixed, you can always remove the plugin!
If you prefer to not use the plugin, you can manually create a admin user and post the login credentials in the “private data” field.Best regards,
NikkoMarch 4, 2019 at 10:08 am #1074257Installed Temporary Login Without Password
Please find the link in the private fieldMarch 5, 2019 at 4:15 pm #1074944Hi pharefm,
I have made some changes however I did made a mistake and was unable to undo the code I added in functions.php.
Can we request for ftp access? so we can undo it and try to tweak the code.Best regards,
NikkoMarch 5, 2019 at 4:52 pm #1074969FTP info
March 5, 2019 at 5:12 pm #1074977Hi pharefm,
Thanks, I tested it out your code and if I checked the values for example in this post (link in private content).
I get id of 41 whether I use $current_post[“the_id”] or get_the_ID().
How can we see this:
I get a notice saying “Undefined index: the_id ”
If I try to use get_the_ID() it only returns 1’sBest regards,
NikkoMarch 5, 2019 at 5:20 pm #1074980I just uncommented the code now, you can check again
the problem is in the blog list view, not the single post view- This reply was modified 5 years, 8 months ago by pharefm.
March 7, 2019 at 7:27 am #1075817Hi pharefm,
Thanks, I have made modifications on your child theme.
First thing I recognize is that I needed to tweak the postslider element and I needed to add this code in functions.php of your child theme:add_filter('avia_load_shortcodes', 'avia_include_shortcode_template', 15, 1); function avia_include_shortcode_template($paths) { $template_url = get_stylesheet_directory(); array_unshift($paths, $template_url.'/shortcodes/'); return $paths; }
You can check here in our docs for more information: https://kriesi.at/documentation/enfold/intro-to-layout-builder/#add-elements-to-alb
Then I created a shortcodes folder in the child theme, copied postslider folder from wp-content > themes > enfold > config-templatebuilder > avia-shortcodes to wp-content > themes > (child theme name) > shortcodes.
Then tweaked postslider.php in the child theme (line 530-531):$current_post['content'] = $entry->post_content; $current_post['title'] = $entry->post_title;
replaced it with:
$current_post['content'] = $entry->post_content; $current_post['title'] = $entry->post_title; $current_post['the_id'] = $the_id;
then in functions.php I modified the avia_audio_content_filter function to:
function avia_audio_content_filter($current_post) { $the_id = $current_post["the_id"]; $match_audio = get_post_meta($the_id, 'audio_file', false); //print "--ID : ".$the_id." <br/>"; if (!empty($match_audio)){ $current_post['before_content'] = do_shortcode('[audio src="'.$match_audio[0].'"][/audio]'); } return avia_default_title_filter($current_post); }
I remove the comment on the print code, so it displays if the ids are accurate.
Best regards,
NikkoMarch 7, 2019 at 3:14 pm #1076003Thank you for the excellent support!
Any chance the postslider.php shortcode could be updated in a future update of the Enfold theme
It’s just one extra line, but would open up many possibilities for different scenarios
(it’d be one less custom file for us to keep updating in case Enfold updates the postslider.php with extra features or introduces breaking changes)Regards
March 7, 2019 at 4:02 pm #1076028Hi pharefm,
I could not assure you that it would be added but please feel free to request such feature at our feature request system: https://kriesi.at/support/enfold-feature-requests/
This system allows us to keep track of user suggestions and lets you vote on the feature you would like to see the most. I am afraid though there is no guarantee that a feature will get implemented.
If it gains a lot of vote then it would most likely be added.
Anyways, we’re glad to help :)Best regards,
NikkoMarch 7, 2019 at 4:37 pm #1076042So far it seems like the form to add requests is disabled
March 11, 2019 at 9:34 pm #1077494Hi pharefm,
Yes, it’s not working at the moment. I’ll forward your request.
Thank you for your input.
Best regards,
Victoria -
AuthorPosts
- You must be logged in to reply to this topic.