adding custom classes for tables

In your case you need to add custom hook for the_content filter: add_filter( ‘the_content’, ‘wpse8170_add_custom_table_class’ ); function wpse8170_add_custom_table_class( $content ) { return str_replace( ‘<table>’, ‘<table class=”mycustom-class”>’, $content ); } Add this snippet to your functions.php file.

options.php problem – data not saved

Add <?php settings_fields( ‘settings-group’ ); ?> <?php do_settings_sections( ‘settings-group’ ); ?> immediately after the <form> tag Your code is registering the settings group, setting up the DB to store the information, but it is/was missing the callback to allow WordPress to actually act on that information or store it. The code I provided tells WordPress … Read more

Remove function or filter

Your problem isn’t that you did the wrong thing, it’s that you did it at the wrong time. When it happens is important, not where. In a child theme, the functions.php is loaded, then the parents, so you’re doing this: Remove the first_paragraph function from the_content filter Add the first_paragraph function to the_content filter Clearly … Read more

Custom Shortcode, functions PHP WP_Query loop

You are returning inside your loop – so it returns on the first iteration, giving you one result only. You should build a string inside your loop instead, and only return when the loop is over. Something like $featured_properties=””; if( $featured_query->have_posts() ): while( $featured_query->have_posts() ) : $featured_query->the_post(); $featured_properties .= get_the_title() . ‘<br />’; endwhile; endif; … Read more

If is multiple page templates

I you want the script be enqueued on page-index.php and page-contact-us.php, then you must check that that page templates are used but you are checking if they are not used. Chagne this: if ( !is_page_template(‘page-templates/page-index.php’) && !is_page_template(‘page-templates/page-contact-us.php’) ) { with: if ( is_page_template(‘page-templates/page-index.php’) || is_page_template(‘page-templates/page-contact-us.php’) ) { The first code reads like: if is NOT … Read more

Trying to count the total number of paragraphs inside a blog article

I’m pretty sure that is_singular() is going to return false when you are inside the WP loop, since there are more than one posts being looped through. Try is_single() or just look at the post object and examine the post_type attribute. add_filter( ‘the_content’, ‘_some_func’, 15 ); function _some_func( $content ) { if( __check_paragraph_count_blog( $content ) … Read more

How the functions in WP are called in tags

There are two separate pieces when you are calling a function: A function declaration. This is mandatory and can only happen once for each function name. A function call. You don’t need to use a declared function, and if you do, you can call the same function multiple times. Both parts must happen in a … Read more

Show only IF not Google bot [closed]

This isn’t really a WordPress specific question. However, I recently wrote a function for this (and blocking other user agents). Perhaps you could use it, or some of it?: function is_a_bot(){ $is_bot = false; $user_agents = array( ‘GTmetrix’, ‘Googlebot’, ‘Bingbot’, ‘BingPreview’, ‘msnbot’, ‘slurp’, ‘Ask Jeeves/Teoma’, ‘Baidu’, ‘DuckDuckBot’, ‘AOLBuild’ ); $user_agent = $_SERVER[‘HTTP_USER_AGENT’]; foreach ( $user_agents … Read more