[Resolved] tag not working
I’m using the <?php global $more; $more = 0; ?> “hack” to make the more-tag work on pages. It works well in the normal content, but not in the mcb-content.
Actually, no. MCB uses the same filters as the normal content. The content seems to be removing the rest on its own.
That means you should use code to show part of the content block. Maybe you can take a look at https://core.trac.wordpress.org/browser/tags/3.8.1/src/wp-includes/post-template.php#L180?
Thanks for your help! But how can i insert some code in MCB? “the more on pages hack” is inserted in the template in the loop right under “<?php while( have_posts() ) : the_post(); ?>”, so i guess there should be some kind of template for MCB where i could insert that hack too?
by reading the linked code, i guess i understand most of that stuff, but we cannot change that, as it’s the wp-source, right?
No, but this is how the WordPress
the_contentfunction works. If you want the same thing for a custom block, you should replicate that code.
So that ‘hack’ won’t work on MCB, since it doesn’t replicate the
the_contentfunction by default.
If you want to show part of a content block, you could use the function
ok, thanks a lot! Where should i add some code to prevent it from beeing overwrtten with a future update?
There is no need to edit the plugin, instead of
the_block( 'Blockname' );you can try something like
echo wp_trim_words( get_the_block( 'Blockname'), 40 );.
If you put it in your template, a plugin update won’t overwrite it. Good luck!
sorry for the delay, i ran out of time…
So now i tried this:
<?php echo wp_trim_words( get_the_block(‘unterer_block_1’), 40 ); ?>
well, it works partially… It cuts the text after 40 word, but it also cuts all html-formats like <h3> and <img> and finally there’s no read-more-link at the end of the stripped text. 3 dots and nothing more.
So i guess i’m stuck again…
if i try <?php the_content( get_the_block(‘unterer_block_2’) ); ?> the text won’t be cut, but the whole text becomes the read-more-link, which is of course not working. But at least the html-formats won’t be cut.
So i guess, we are on the right way, but there’s still some way to go…
<?php echo strstr( get_the_block('unterer_block_2'), '<!--more-->', true ); ?>?
Warning: Wrong parameter count for strstr() in /WWWROOT/227712/htdocs/wp-content/themes/responsive-child/Inhalt_Sidebar_Block_unten.php on line 75
The last parameter was added from PHP 5.3. Maybe you have a lower version.
I’m glad to help you when there’s a problem / bug with my plugin, but this is just one of the implementations you could do with it. In my opinion, this is more PHP support.
I think I’ve given you a lot of pointers for where to look, but I’m afraid I don’t have time to answer all PHP support questions. Good luck!
Ok, thanks a lot. If i get it running, i’ll post it here. If not, i’m dead 😀
- The topic ‘[Resolved] tag not working’ is closed to new replies.