Sharing templates with the JSON API?

You can use wp_localize_script();: // Example: wp_register_script( ‘your-template-script’, $path, $dependencies, $version, true ); wp_enqueue_script( ‘your-template-script’ ); wp_localize_script( ‘your-template-script’ ,’your_template_object’ ,array( ‘ajaxurl’ => admin_url( ‘admin-ajax.php’ ) ,’template_nonce’ => wp_create_nonce( self :: $search_nonce_val ) ,’action’ => ‘build_template’ ,’title’ => get_the_title() ,’content’ => get_the_content() ,’title_format’ => ‘h1’ ) ); Then you can use it in your template.js file … Read more

Post formats template

Post formats are used to customize posts according to their “meta” content, but they are always posts and as posts they will be listed on archive and category pages. What is parent template file that is used when there is no specified template file and what is specified template file that covers all post formats … Read more

How Can I Have A URL Changed Based on the Originating URL?

You can use the page_link filter with the same logic as the page_template filter in the other answer. If the endpoint query var is set, then any link to a page gets the app-view/ appended: function wpd_page_link( $link, $post_id ){ global $wp_query; if( isset( $wp_query->query_vars[‘app-view’] ) ){ return $link . ‘app-view/’; } return $link; } … Read more

TwentyTen: Overloading template.php files vs. get_template_part

TwentyTen was designed to help understand the WordPress theming system and that is why it has more lines of comments then actual code. So looking at TwentyTen you need to understand that they tried to include every file in the Template Hierarchy (eg: attachment.php, single.php, page.php) and every template tag there is (including: get_template_part() which … Read more

Blank on static home page?

From the Codex If you are using a custom homepage with custom loops and stuff or a custom front-page, you will have an empty wp_title. Here goes a neat hack to add the description/tagline at the wp_title place on homepage: add_filter( ‘wp_title’, ‘baw_hack_wp_title_for_home’ ); function baw_hack_wp_title_for_home( $title ) { if( empty( $title ) && ( … Read more

How To Remove The “Click here to cancel reply” Link From The WordPress Comment Form

add_filter( ‘cancel_comment_reply_link’, ‘__return_false’ ); See /wp-includes/comment-template.php#function get_cancel_comment_reply_link() for more background. But if you do that the reply form will not move to the comment. The more interesting question is: Why doesn’t the link work for you? Do you have this line in your footer? is_singular() and get_option( ‘thread_comments’ ) and wp_print_scripts( ‘comment-reply’ );

page_template toggle between 2 templates + 2 permalinks for same post

WordPress has a simpler function for what you’re trying to do, add_rewrite_endpoint. Additionally, the filter for a single post template is single_template, page_template fires on the page post type. function wpd_detail_endpoint(){ add_rewrite_endpoint( ‘detail’, EP_PERMALINK ); } add_action( ‘init’, ‘wpd_detail_endpoint’ ); function wpd_detail_template( $template=”” ) { global $wp_query; if( ! array_key_exists( ‘detail’, $wp_query->query_vars ) ) return … Read more

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