Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1075555

    Hi I am trying to create a block of content that I can insert into different posts. The way that I think would be easiest to do this is to design a page using the Advanced Editor and then using the “Insert Theme Shortcode” > “Page Content” and place the page. The posts are all regular posts (not using the Advanced Layout Editor).

    The problem is that when the page is shown the other page is inserted but the shortcode isn’t formatted. Is there any way to do this with the method I came up with or should I try something different?

    The end goal is to have a few different footer type content blocks that I can insert after different blog posts dependent on the call to action that would make the most sense.

    #1075585

    Hi,

    I’m using the get_footer action to add a image to the top of the footer of all my pages. You could just a conditional in there to detect which page/post/category etc and then output different $content for each one.

    add_action('get_footer', 'footer_image');
    function footer_image() {
      $content = '<div id="myid">formatted html to be added</div>
    ';
      echo $content;
    }

    Hope this helps.

    #1075695

    That is an interesting idea. I wonder if you could output a page based on the page id? Also, it would be important to be able to handle the Enfold shortcodes.

    I like that idea in principle.

    #1076883

    Hi,
    You can create a shortcode that will output the content of a post. For this example I’m going to get post ID 68
    with this shortcode on my page:

    [postsc]

    I added this code to the end of my functions.php file in Appearance > Editor:

    
    function post_shortcode( ) {
      $content = get_post_field('post_content', 68);
      return $content;
      
    }
    add_shortcode( 'postsc', 'post_shortcode' );

    2019-03-09-204909

    Best regards,
    Mike

    #1077219

    That shortcode works to pull the content in, but leaves all of the advanced layout elements in their raw shortcode format rather than styled correctly.

    #1077463

    I found this from another post. If I add “do_shortcode();” to the function you gave me it works. So I added:
    function post_shortcode( ) {
    $content = do_shortcode(get_post_field(‘post_content’, 68));
    return $content;

    }
    add_shortcode( ‘postsc’, ‘post_shortcode’ );

    And it worked.

    #1077634

    Hi,
    Good catch, I had only tested on a classic editor post, but I’m glad you figured it out.
    I’m sure others will find it useful. Unless there is anything else we can assist with on this issue, shall we close this then?

    Best regards,
    Mike

    #1077841

    Yes, this was great. We can consider it closed.

    #1078058

    Hi,
    Glad we were able to help, we will close this now. Thank you for using Enfold.

    For your information, you can take a look at Enfold documentation here
    For any other questions or issues, feel free to start new threads under Enfold sub forum and we will gladly try to help you :)

    Best regards,
    Mike

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Insert Advanced Layout page into a normal Post’ is closed to new replies.