Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #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’s

    What should I use?

    #1073228

    any help?

    #1073326

    Hi pharefm,

    Can you share your code with us?

    Best regards,
    Victoria

    #1073338
    if(!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);
    		
    	}
    }
    #1074252

    Hi pharefm,

    Please post us your login credentials (in the “private data” field), so we can take a look at your backend.

    1. Install and activate ” Temporary Login Without Password “.
    2. Go to ” Users > Temporary Logins ” on the left-side menu.
    3. Click ” Create New “.
    4. 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 ).
    5. Click ” Submit “.
    6. 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,
    Nikko

    #1074257

    Installed Temporary Login Without Password
    Please find the link in the private field

    #1074944

    Hi 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,
    Nikko

    #1074969

    FTP info

    #1074977

    Hi 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’s

    Best regards,
    Nikko

    #1074980

    I 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, 9 months ago by pharefm.
    #1075817

    Hi 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,
    Nikko

    #1076003

    Thank 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

    #1076028

    Hi 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,
    Nikko

    #1076042

    So far it seems like the form to add requests is disabled

    #1077494

    Hi pharefm,

    Yes, it’s not working at the moment. I’ll forward your request.

    Thank you for your input.

    Best regards,
    Victoria

Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.