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

Template tags to display custom post type posts in category template?

Custom post types are by default excluded from the main query except on taxonomy pages and custom post type archives. You can simply use pre_get_posts to correctly alter the main query (alter the query variables before the SQL query is build and executed) to your needs. Just a few notes on pre_get_posts pre_get_posts runs front … Read more

How to load different CSS in different Header?

Enqueue style depending on a template filename: if(‘header.php’ == basename( get_page_template() ) { // check the template file name // enqueue header.php style here } if(‘header-full.php’ == basename( get_page_template() ) { // check the template file name // enqueue header-full.php style here } wp_enqueue_style already registers a style so you don’t need to register a … Read more

Creating a custom category page with pagination

You have a few issues here The following piece of code is wrong and unnecessary $category = get_post(); $category = $category->post_title; The current page object is saved in get_queried_object(), so you can use this function to get your post title. Also, post_title is not the correct property to use here. You want to look at … Read more

On this day PHP code

Adapted from the Codex, tweaking WP_Query to get all years before this. Untested, but should work. $on_this_day = array( // remove the year from the first query array ‘monthnum’ => date(‘n’), ‘day’ => date(‘j’); ); // Create a new filtering function that will add our where clause to the query function filter_where( $where=”” ) { … Read more