Get page IDs based on which template they are using?

WP_Query goes only through posts by default. Try adding page as your post type: $the_query = new WP_Query(array( ‘post_type’ => ‘page’, /* overrides default ‘post’ */ ‘meta_key’ => ‘_wp_page_template’, ‘meta_value’ => ‘templates/_partner.php’ )); See: WP_Query – Type Parameters

Show Woocommerce minicart widget in checkout page sidebar? And, how to make this update secure by overriding widget?

The cart widget isn’t showing because it’s configured to not show on the cart and checkout page. If you want to change that take a look at class-wc-widget-cart.php, there you find the following line: if ( is_cart() || is_checkout() ) return; Change it to: if ( is_cart() ) return; To show the widget on the … Read more

Template for specific post of custom post type

For the templates WordPress uses, please always refer to Template hierarchy scheme in the Codex. As you can see there, single-{$posttype}-{$slug}.php does not exist, there is only single-{$posttype}.php. To do what you want, have a look at the filter ‘single_template’: add_filter( ‘single_template’, function( $template ) { global $post; if ( $post->post_type === ‘event’ ) { … Read more

How to Rename a Template File?

Chris gave me some good insight, and I appreciate the filter func. But I wound up changing the db through phpMyAdmin: UPDATE wp_postmeta SET meta_value=”new-filename.php” WHERE meta_value=”old-filename.php”;

How to customize the default HTML for WordPress Attachments

I want to change the default HTML code structure so that I can insert additional tags Run a filter on img_caption_shortcode, you can find that hook in the source here. http://core.trac.wordpress.org/browser/tags/3.0.1/wp-includes/media.php#L720 Example add_filter( ‘img_caption_shortcode’, ‘my_caption_html’, 10, 3 ); function my_caption_html( $current_html, $attr, $content ) { extract(shortcode_atts(array( ‘id’ => ”, ‘align’ => ‘alignnone’, ‘width’ => ”, … Read more

Customizing get_the_excerpt() to specific length and “Read More” output.

To get a specific length you can use: wp_trim_words function. It has 3 parameters. Text to trim. Ex: get_the_content() Number of words. Ex: 295 What to append after end of the text. Ex: ” This means null. Use this: <span> <?php echo wp_trim_words( get_the_content(), 295, ” ); ?> <i><a style=”color:#1975D1;float:Right;” class=”title” href=”https://wordpress.stackexchange.com/questions/75069/<?php the_permalink() ?>” rel=”bookmark”>Click … Read more

Change the name of the ‘Default Template’

There is a filter for this since version 4.1; cf. https://github.com/WordPress/WordPress/commit/7cdbac53e8497b346d1009375d36586fb6e5197c You can now use: add_filter(‘default_page_template_title’, function() { return __(‘My default template name’, ‘your_text_domain’); });

How to show a under construction page for a domain but still be able to work on index.php?

You can filter template_include and include a special file for users who are not logged in: /* Plugin Name: T5 Under Construction */ add_filter( ‘template_include’, ‘t5_uc_template’ ); function t5_uc_template( $template ) { $uc_template = dirname( __FILE__ ) . ‘/under-construction.php’; if ( ! is_user_logged_in() ) return $uc_template; if ( ! current_user_can( ‘administrator’ ) ) return $uc_template; … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)