How can i know when i can execute what functions of wordpress?

I like to do a bunch of stuff only on homepage and archive pages i am working with the genesis framework (not really matters i guess) if( is_singular() ) { wp_die(‘functions.php’); } add_action( ‘init’, function() { if( is_singular() ) { wp_die(‘init’); } }); add_action( ‘genesis_before’, function() { if( is_singular() ) { wp_die(‘genesis_before’); } }); only … Read more

Disable feeds for specific custom post types

I want to remove the feeds for specific custom post types. Most recommended methods are not clean. There seems to be a option called $args->feeds but this does not work within the register_post_type() function. register_post_type( … ‘rewrite’ => array(‘slug’ => ‘slug/%term&’, ‘with_front’ => false, ‘feeds’ => false), // Remove feed rewrite-rules? … ); Source: Line … Read more

Changing a WordPress core function without hacking core

I am looking to change one line within a core function. The function is wp_allow_comment() located within /wp-includes/comment.php function wp_allow_comment($commentdata) { global $wpdb; extract($commentdata, EXTR_SKIP); // Simple duplicate check // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content) $dupe = $wpdb->prepare( “SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = %s AND comment_approved != ‘trash’ AND … Read more

Question about the template-loader.php file

I am studying the WP code and have a doubt regarding the end of the /wp-includes/template-loader.php file, which handles the template that must be loaded for a certain URL request. if($template = apply_filters(‘template_include’, $template)){ include($template); }elseif(current_user_can(‘switch_themes’)){ $theme = wp_get_theme(); if($theme->errors()){ wp_die($theme->errors()); } } The first part is very clear. A certain template has been set … Read more

How to show updated edit on preview URL without clicking preview button

http://localhost/demosite/?page_id=19&preview=true ^ This is the preview URL for a page with id 19, now whenever I made some changes to it’s page content and refresh above URL it don’t show the latest changes I made unless I click preview button, I think preview button trigger some kind of function which save page and then above … Read more

Headers already sent – WordPress core

I’m getting an error on my site regarding “headers already sent”: Warning: Cannot modify header information – headers already sent by (output started at ………/wp-admin/menu-header.php:161) in ……/wp-includes/pluggable.php on line 881 I read the WordPress FAQ that discusses this, but – as you can see – this error is caused by the WordPress core (and not … Read more

Why use while over if in single wordpress posts?

Why is while() used instead of say if() here: <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( ‘content’, ‘single’ ); ?> <?php _s_post_nav(); ?> <?php // If comments are open or we have at least one comment, load up the comment template if ( comments_open() || ‘0’ != get_comments_number() ) : comments_template(); endif; … Read more