Wordpress barcode not working

I built a very unique and javascript intensive wordpress theme and now shortcodes do not work. I have no plugins, so this is not the case. What have I lost from my wordpress template files, which are necessary for using short codes (for example: [gallery]).

I understand how to make short codes, but how does WP take your post and replace “[gallery]” when it spits it out for display?

EDIT: here is what I am working with:

$pagepull = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'page' AND post_status = 'publish' ORDER BY menu_order", ARRAY_A); $i = 1; foreach ($pagepull as $single_page){ echo "<div class=\"section\"><ul><li class=\"sub\" id=\"" . $i . "\"><div class=\"insection\">"; echo $single_page['post_content']; $i++; // more code that is irrelevant... // more code that is irrelevant... // more code that is irrelevant... } 
+4
source share
5 answers

Ok try

  $pagepull = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'page' AND post_status = 'publish' ORDER BY menu_order", ARRAY_A); $i = 1; foreach ($pagepull as $single_page){ echo "<div class=\"section\"><ul><li class=\"sub\" id=\"" . $i . "\"><div class=\"insection\">"; echo apply_filters('the_content',$single_page['post_content']); $i++; 

Wordpress accepts your content and applies filters to it. You must register the filter and analyze the content.

If your topic does not display your shortcodes, you are likely to display the message content, preventing Wordpress from filtering it.

Calling the get_the_content () function for a message does not trigger a filter for short codes (if any).

To apply

 <?php apply_filters('the_content',get_the_content( $more_link_text, $stripteaser, $more_file )) ?> 

Link: http://codex.wordpress.org/Function_Reference/get_the_content

Note: many plugins register content filters for implementing shortcodes!

+11
source

use this if you want the contents inside the variable:

 ob_start(); the_content(); $content = ob_get_clean(); 

now you can just do echo $ content; or use a regex or whatever you want the content to look the way you want.

+1
source

I had the same problem.

Barcodes depend on WP Loop, but this is a different issue. In short, I added the_post(); on the page where the short code should be displayed (for example, articles.php ).

Also, make sure you use the_content() to display the text (for example, $post->post_data will not show you $post->post_data ).

+1
source

My solution replaced

 <?= get_the_content() ?> 

with

 <?= the_content() ?> 

which, as already mentioned, applies filters before returning the content.

Read this carefully about the_content

0
source

Please, use

 ob_start(); 

at the beginning of the function and use

 return ob_get_clean(); 

before closing the function.

Hope this helps you to the fullest.

Greetings

0
source

Source: https://habr.com/ru/post/1337257/


All Articles