Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #824946

    So I wrote a php function in its own php file and saved it in the wp-content folder. I’ve also included the file in the child theme’s function.php file, and I’ve added a shortcode based on that function. When I call the shortcode from a page without the Advanced Layout Builder, everything looks fine. When I add the shortcode inside a code block of the advanced layout builder, the page loads the shortcode’s output and then loads everything else in the layout builder. If I put the shortcode inside of a text block it improves the situation slightly… It will load the shortcode’s output within the main content container, but not within the <div> tags of the textblock, so essentially the whole layout is still not working. Any suggestions?

    #826737

    Hey colencrawford,

    I think we would need to see the actual code if you need help with that.

    Best regards,
    Rikard

    #828735

    This is the simplest example of the problem.

    function welcome_user(){
    	$current_user = wp_get_current_user();
    	
    	if( $current_user -> ID == 0){ //if no one is logged in, redirects to login page
    		?>
    		<META HTTP-EQUIV="Refresh" CONTENT="0;URL=index.php/login">
    		<?php
    	} else {
    		echo'<H1>Welcome ' . $current_user -> user_firstname . '!</H1>';
    	}
    }

    This is saved in the wp-content folder as a file named the same as the function. In the functions.php file I have:

    include(WP_CONTENT_DIR . '/welcome_user.php');
    add_shortcode('welcome_user', 'welcome_user');

    Then I added the shortcode to the page. I’ve tried both the textbox and the code block. Both work when it comes to adding the content, except that it loads the shortcodes content before it adds anything else in the avia layout builder.

    #829771

    I also tested this by just adding the function (welcome_user) directly in the functions.php file and creating the shortcode there. Same problem occurs.

    #829774
    #829783

    Wow, thanks for the help! That solved my problem. That one’s been racking my brain for a week now.

    #829788

    Hey!

    You are welcome! On the bright side, you will not have this issue in future and that will make up the time :)

    For your information, you can take a look at Enfold documentation here – http://kriesi.at/documentation/enfold/
    And if there are features that you wish Enfold had, you can request them and vote the requested ones here – https://kriesi.at/support/enfold-feature-requests/
    For any other questions or issues, feel free to post them here on the forum and we will gladly try to help you :)

    Best regards,
    Yigit

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Custom Shortcode's Output Isn't Contained by’ is closed to new replies.