Proper way to get page content
I’ve answered my own question. Call apply_filter and there you go. <?php $id=47; $post = get_post($id); $content = apply_filters(‘the_content’, $post->post_content); echo $content; ?>
I’ve answered my own question. Call apply_filter and there you go. <?php $id=47; $post = get_post($id); $content = apply_filters(‘the_content’, $post->post_content); echo $content; ?>
Try this : <?php global $woocommerce; $items = $woocommerce->cart->get_cart(); foreach($items as $item => $values) { $_product = wc_get_product( $values[‘data’]->get_id()); echo “<b>”.$_product->get_title().'</b> <br> Quantity: ‘.$values[‘quantity’].'<br>’; $price = get_post_meta($values[‘product_id’] , ‘_price’, true); echo ” Price: “.$price.”<br>”; } ?> To get Product Image and Regular & Sale Price: <?php global $woocommerce; $items = $woocommerce->cart->get_cart(); foreach($items as $item => … Read more
No need to create custom walker. Just use additional argument and set filter for nav_menu_css_class. For example: $args = array( ‘container’ => ”, ‘theme_location’=> ‘your-theme-loc’, ‘depth’ => 1, ‘fallback_cb’ => false, ‘add_li_class’ => ‘your-class-name1 your-class-name-2′ ); wp_nav_menu($args); Notice the new ‘add_li_class’ argument. And set the filter on functions.php function add_additional_class_on_li($classes, $item, $args) { if(isset($args->add_li_class)) { … Read more
Simple function to print from the filter array? function print_filters_for( $hook = ” ) { global $wp_filter; if( empty( $hook ) || !isset( $wp_filter[$hook] ) ) return; print ‘<pre>’; print_r( $wp_filter[$hook] ); print ‘</pre>’; } Call it where you need it. print_filters_for( ‘the_content’ );
You can get that using the following methods: <?php $post_slug = get_post_field( ‘post_name’, get_post() ); ?> Or You can use this easy code: <?php global $post; $post_slug = $post->post_name; ?>
You have to add “wordpress” to the intelephense.stubs array setting in your VS Code settings file. This array should probably also have many other stubs listed as well. For example: (“wordpress” is at the bottom) // VS Code settings.json { // … other settings here … “intelephense.files.maxSize”: 3000000, “intelephense.stubs”: [ “apache”, “bcmath”, “bz2”, “calendar”, “com_dotnet”, … Read more
Best solution here http://wordpress.org/support/topic/add-backend-page-without-menu-item use add_submenu_page with parent slug = null
There is no option for this, but you can extend the ‘walker’ object that WordPress uses to create the menu HTML. Only one method needs to be overridden: class My_Walker_Nav_Menu extends Walker_Nav_Menu { function start_lvl(&$output, $depth) { $indent = str_repeat(“\t”, $depth); $output .= “\n$indent<ul class=\”my-sub-menu\”>\n”; } } Then you just pass an instance of your … Read more
I would suggest to use a WordPress internal constant to solve this case: $my_plugin = WP_PLUGIN_DIR . ‘/my-plugin’; if ( is_dir( $my_plugin ) ) { // plugin directory found! } Alternative The other valid alternative is to compute the path from the URL which is more complex/confusing. I would not use this code: $plugins_url = … Read more
There is a meta capability create_posts that is documented here and is used by WordPress to check before inserting the various ‘Add New’ buttons and links. In your custom post type declaration, add capabilities (not to be confused with cap) and then set it to false as below. register_post_type( ‘custom_post_type_name’, array( ‘capability_type’ => ‘post’, ‘capabilities’ … Read more