Support

Account

Home Forums Gutenberg How do I place post-specific ACF Gutenburg block in sidebar?

Unread

How do I place post-specific ACF Gutenburg block in sidebar?

  • On my website I have an archive of news stories that I wrote during my previous career as a journalist.

    All of these posts have a custom Gutenburg block that includes metadata about the print version of the article. Right now that block appears within the main site content area beneath the headline, however, I would like it to appear in the sidebar.

    Here is an example of one of those posts:

    https://www.nathaniel.ca/2007/09/27/majority-of-queer-couples-not-married/

    Secondly, here is an example of what I would like to do:

    https://www.jw.org/en/library/magazines/awake-no1-2022/world-turmoil-how-to-cope/

    You’ll notice that this post has post-specific content in the sidebar.

    Here is the block in question:

    acf_register_block_type(array(
    					'name'              => 'pdfdownload',
    					'title'             => __('PDF Download'),
    					'description'       => __('A block for PDF downloads.'),
    					'render_template'   => 'template-parts/blocks/pdfdownload/pdfdownload.php',
    					'category'          => 'formatting',
    					'icon'              => 'media-text',
    					'keywords'          => array( 'PDF', 'Download' ),
    				));
    <?php
    
    /* PDF Download */
    
    $pdf_download = get_field('pdf_download') ?: 'PDF Download';
    $newspaper_clipping = get_field('newspaper_clipping') ?: 'https://www.nathaniel.ca/wp-content/uploads/2021/05/Newspaper-Clipping-for-website-1.png';
    
    ?>
    <div class="print-version">
    	 
    <span class="print-version-meta">
    	<h6><span class="print_version_headline"> <? echo "Print Version" ?> <a href="<?php the_field('pdf_download'); ?>">(Download PDF)</a></span></h6>
    			</span>		
    <span class="news-clipping">
      <a href="<?php echo $pdf_download; ?>"><img src=" <?php echo $newspaper_clipping ?> "></a>
    	</span>
    </span>
    	</div>
    

    Thank you in advance for any guidance!

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.