Displaying MB Blocks Multiple Ways?

Support MB Blocks Displaying MB Blocks Multiple Ways?Resolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #46306
    Andrew TegenkampAndrew Tegenkamp
    Participant

    I've created an MB Block that lets you pick a related post in order to create a "post of posts" to let editors highlight old posts, featured content, or even call out a related post.

    It works well, but I'd like to display it differently based on the post template being used. I know I could add an attribute to the MB Block, but I'd like to be able to read the post template while rendering the MB Block. Is that possible in the front end, back end, or both?

    Thanks!

    #46340
    PeterPeter
    Moderator

    Hello Andrew,

    I'd like to display it differently based on the post template being used

    Can you please clarify this sentence? What do you mean to display it differently?

    #46341
    Andrew TegenkampAndrew Tegenkamp
    Participant

    Hi,

    I'm sorry for not following up on this as I believe I found the answer in the default WP docs.

    To clarify, I was hoping to show the Gutenberg block I created differently on different post/page templates. I am able to read the page template using code below, and added an if statement based on the result.

    If you or anyone else has other or better suggestions, I'm definitely open to other ideas, too.

    
    function metabox_render_callback($attributes) {
    	//echo get_the_ID().'='.get_page_template_slug(get_the_ID()); //current postID and template
    	//if statement based on get_page_template_slug result
    }
    

    Thanks for following up, and I believe this is solved 🙂

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