zarwell
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: How to display custom fields in WP 6.1 FSE pagesThanks again, but nothing seems to work. I have tried both with and without the free ACF plugin, but regardless I don’t get Custom Fields or anything like it in the block search. In the video I provided I had ACF disabled, but I’ve activated it again to try. No luck. I have been able to use shortcode, [acf field=”location_latitude”], to insert the post field successfully into a post, but only in the admin editor. I can’t get anything to work adding it to a page.
Thanks for the article you provided, but it like everything else I’ve found online only provides examples for doing this with PHP.
Any idea why I don’t see Custom Fields anywhere in my Blocks? Anything else I can try?
Forum: Developing with WordPress
In reply to: How to display custom fields in WP 6.1 FSE pagesThx for the very quick response. This might explain why I’m stuck, I don’t see Custom Fields when searching blocks in a post or page. Here’s a video of what I get: https://www.screencast.com/t/so5xfsKwOzx0
Is my theme not being identified correctly or something?Thanks so much for that. After knowing that I found this and added it to my theme’s function.php. Things are working perfectly now with block gallery.
function get_post_block_galleries_images( $post_id ) { $content = get_post_field( 'post_content', $post_id ); $srcs = []; $i = -1; foreach ( parse_blocks( $content ) as $block ) { if ( 'core/gallery' === $block['blockName'] ) { $i++; $srcs[ $i ] = []; preg_match_all( '#src=([\'"])(.+?)\1#is', $block['innerHTML'], $src, PREG_SET_ORDER ); if ( ! empty( $src ) ) { foreach ( $src as $s ) { $srcs[ $i ][] = $s[2]; } } } } return $srcs; }
Thanks for the help. I still can’t see what’s wrong here. I have posts with galleries and with images and no images or are showing with this code, just the title, poster, date and message.
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); $galleries = get_post_galleries_images( get_the_ID() ); foreach($galleries as $image) { echo '<img src="' . $image . '" />'; } ?> <?php get_template_part( 'entry' ); ?> <?php comments_template(); ?> <?php endwhile; endif; ?>
- This reply was modified 4 years, 8 months ago by zarwell.
Thanks again Joy. It’s still not working, nothing is being output. I feel bad taking up your time without much to work off of. I’m going to keep digging and I’ll post an answer for others if/when I find it. Below is the current state of my code:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); $galleries = get_post_galleries_images( get_the_id() ); foreach($galleries as $image) { echo '<img src="',$image,'" />'; } ?> <?php get_template_part( 'entry' ); ?> <?php comments_template(); ?> <?php endwhile; endif; ?>
- This reply was modified 4 years, 8 months ago by bcworkz. Reason: code fixed
Thanks Joy, I was in the middle of making changes when I pasted the code so the second one wasn’t really a problem, my bad on that one. On the first, I’ve tried passing in several things, including the_post() with no success. What should be passed in?
cpt_copcyat, did you ever find a good solution to this? I’m really surprised alternative product views aren’t a core part of woocommerce, given all the features it does have.