Tagged: Codeblock, Shortcodes
-
AuthorPosts
-
July 21, 2017 at 4:38 am #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?
July 22, 2017 at 5:17 am #826737Hey colencrawford,
I think we would need to see the actual code if you need help with that.
Best regards,
RikardJuly 23, 2017 at 7:29 pm #828735This 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.
July 25, 2017 at 8:12 pm #829771I also tested this by just adding the function (welcome_user) directly in the functions.php file and creating the shortcode there. Same problem occurs.
July 25, 2017 at 8:16 pm #829774Hi!
Please refer to this post – https://stackoverflow.com/questions/23334359/wordpress-shortcodes-in-the-wrong-place
Cheers!
YigitJuly 25, 2017 at 8:39 pm #829783Wow, thanks for the help! That solved my problem. That one’s been racking my brain for a week now.
July 25, 2017 at 8:53 pm #829788Hey!
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 -
AuthorPosts
- The topic ‘Custom Shortcode's Output Isn't Contained by’ is closed to new replies.