WordPress Child Themes

It is somewhat counter-intuitive but WordPress loads child’s theme code before parent’s theme. So wrapping anything in function_exists() in child theme does nothing, it’s parent theme that needs to have that. Better option is to unhook parent’s theme function (unless it’s run right at load, which it should not do) and hook your own.

If has $title in widgets

Should be possible like this: <?php /** @see WP_Widget::widget */ function widget( $args, $instance ) { extract( $args ); $title = apply_filters( ‘widget_title’, $instance[‘title’] ); # >>>> NEW if ( ! isset( $title ) OR empty( $title ) ); return; # <<<< NEW echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; … Read more

Custom field values to taxonomy terms

Don’t have a time to test it now but something like this should work: // Change or add your own arguments as needed $args = array( ‘post_type’ => ‘post’, ‘numberposts’ => -1, ‘offset’ => 0 ); $my_posts = get_posts( $args ); if ( $my_posts ) { foreach ( $my_posts as $my_post ) { $meta = … Read more

PHP code to use on next & previouspage links

adjust the ‘nextpagelink’ and ‘previouspagelink’ arguments for wp_link_pages() to have a css class you can style $args = array( ‘nextpagelink’ => ‘<span class=”next”>’ . __(‘Next page’) . ‘</span>’, ‘previouspagelink’ => ‘<span class=”prev”>’ . __(‘Previous page’) . ‘</span>’ ); wp_link_pages($args); then in your css you can style those spans to use your arrows as background images.

running arbitrary php files

WordPress offers a dedicated API for your need: the Plugin API. So (let) write a plugin, which is really easy. Then you can use the extra code probably without conflicts.

Accessing WPDB Multidimensional JSON Array w/ Javascript

Looks like you want to use something like result = $.parseJSON(data). Then you can access the data with result.win_id, for example. As an aside, you should sanitize the input to that database query using prepare with something like: $wpdb->get_results( $wpdb->prepare( “SELECT * FROM wp_winners WHERE user_id=%d”, $user_id ) );

Sort by page information by Ascending Numbers

Use custom fields wp_query Ex <?php $args = array( ‘post_type’ => ‘page’, ‘meta_query’ => array( array( ‘key’ => ‘mytitle’, ‘value’ => ‘title’, ‘orderby’ => ‘mytitle’, ‘order’ => ‘DESC’ ), ) ); $query = new WP_Query( $args ); if ( have_posts() ) while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?> <tr> <td><?php echo the_field(‘educational_ranking’); ?></td> <td><a href=”https://wordpress.stackexchange.com/questions/60150/<?php … Read more