Problem with More-tag using "custom post type UI" (it aint working)

So I am trying to use the more tag in my custom post type, but it is not working, anyone know why this is?

I have tried setting the global variable to zero but no difference, the whole posts is displayed anyway.

the field I want to use the more tag in is <?php the_field(‘information’); ?>



<?php

<?php

		$args = array(

			'post_type' => 'tjanster'

		);

		$the_query = new WP_Query( $args );

	?>

	<?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

	<div class="container row" style="background: <?php the_field( 'bgcolor'); ?>" >
		<div class="block-7 col info" style="color: <?php the_field( 'txtcolor'); ?>">

				<h3 style="color: <?php the_field( 'txtcolor'); ?>"><?php the_field( 'rubrik'); ?></h3>
				<p>
					<?php
						global $more;
						$more = 0;
						the_field( 'information');
					?>
				</p>

		</div>
		<div class="block-5 col">

			<img src="<?php the_field( 'bild'); ?>" />

		</div>
	</div>

	<?php endwhile; else: ?>

		<p>There are no posts</p>

	<?php endif; ?>


hello there,

You can try this trick instead :

In your theme functions.php file add this :


function custom_field_excerpt() {
	global $post;
	$text = get_field('information');
	if ( '' != $text ) {
		$text = strip_shortcodes( $text );
		$text = apply_filters('the_content', $text);
		$text = str_replace(']]>', ']]>', $text);
		$excerpt_length = 30; // 30 words
		$excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
		$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
	}
	return apply_filters('the_excerpt', $text);
}

then use this : <?php echo custom_field_excerpt(); ?> to display the custom field you want… in this example it will show 30 words…

Goodluck

Thanks dude, works fine.

You are Welcome :wink: