Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1158538

    Hi, I am using a filter to add an author bio box to the end of every post.
    The problem is that I have a Page set as a footer in Enfold’s footer settings, and it seems that the content I am adding gets added to the end of the footer as well.
    Here it is:

    My code is along the lines of this:

    
    function auto_insert_after_post($content){
    if (is_single()) {
    $content .= 'The block of text you want to add goes here';
    }
    return $content;
    }
    add_filter( "the_content", "auto_insert_after_post" );
    
    #1158541

    you mean this:

    and that should be under each post ( or portfolio too?)

    maybe you can use that filter here : avf_template_builder_content
    but it does only work if your single posts are made with advanced layout builder.

    it is used this way:

    add_filter('avf_template_builder_content', 'avf_template_builder_content_mod', 10, 1);
    function avf_template_builder_content_mod($content = "")
    {
      if(is_single() || is_singular('portfolio') ) {
        $addendum = do_shortcode(" enfold shortcode place it here between ");
        $content = $content . $addendum ;
      }
      return $content;
    }

    you have to be carefull with the shortcode insertion – because this have to be a oneliner and inline styles are complicated to have – besides that you can not use fullwidth containers as color-sections or grid-rows – because otherwise the sidebar goes down under this.
    how to get from enfold the enfold shortcode is known ?

    #1159677

    Hi,
    Thank you for sharing @Guenni007

    Best regards,
    Mike

    #1160282

    Hi, thanks but going back and converting everything to advanced layout builder is a lot of work, and just a workaround really.
    Is there a “normal” solution?
    The problem stems from using a page as the footer, whereby Enfold places a “page” content type at the bottom of each webpage. This is weird since appending content via is_single is specific to “posts”.
    What’s even stranger is that on normal “page” post types, the author bio box is not added, even though the footer is there:

    If there is no immediate way to fix this, I will just revert to using widgets in the footer.
    But it would be nice to keep this wide footer, it’s nice and modern :-)
    Thanks,
    Tom

    #1161244

    Please reply to my question Enfold support, thanks.

    #1161245

    Hi,

    Try to look for a unique content in the custom footer page that is not available or present in the single post pages, and use it to create another conditional statement inside the “the_content” filter.

    function auto_insert_after_post($content){
    	if (is_single() && strpos($content, '© 2019') === false) {
    		$content .= 'The block of text you want to add goes here';
    	}
    	return $content;
    }
    add_filter( "the_content", "auto_insert_after_post" );
    

    This checks for the “© 2019” string or text and if not found, it will return the default content without the author bio box. If you want it to be more specific or make sure that the conditional statement succeeds, create an invisible element inside the custom footer page, add a random text in it, then use it as the needle in the strpos function instead.

    // https://www.php.net/manual/en/function.strpos.php

    Best regards,
    Ismael

    #1161269

    Thanks this workaround works!
    It would be nice to fix this in a future release though :-)
    Best,
    Tom

    #1161763

    Hi,

    Glad that the modification works. This is not a bug. Both the single.php or the includes > loop-index.php file and template used for the advance layout builder contains or executes the “the_content” filter, so it’s expected that the additional content will be added on both.

    Best regards,
    Ismael

    #1161776

    Even though it is technically expected behavior, it is not what the user intends.
    The post content and the footer are different animals. As a user, I would want to inject something in either the post it the footer, but I can’t think of any reason to inject the same thing in both places.
    So even though you don’t call it a bug, it is a problem that should be solved.
    Best
    Tom

    #1161826

    Hi!

    Even though it is technically expected behavior, it is not what the user intends.

    Yes, that’s true. However, by using the filter, you should be aware that it is used by both templates and that you’re modifying the default behavior of the theme or adding a new feature to it. You are in a way responsible for that modification, so in order to make it work properly, adding the conditional statement is required. It’s a normal way to extend an existing feature, so you can leave the modification as is if you haven’t found a “better” way to solve it.

    Best regards,
    Ismael

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