Odd functions.php issue in WordPress

There is no WordPress function called meta(). Try using get_post_custom() (Codex ref) instead. For example: //Address add_action( ‘woo_post_inside_before’, ‘my_address’ ); function my_address() { if ( is_single() && in_category(‘listings’) ) { global $post; $meta = get_post_custom(); echo ‘<h1>’ . $meta[‘address’] . ‘</h1>’; } } Note: I’m not sure you need to call global $post; in this … Read more

the_excerpt function not showing image

If you did not set an explicit excerpt for your post in the post editor, WordPress by default calls wp_trim_excerpt() to auto-generate an excerpt. This function throws out all HTML tags to make life simple. the_content() does not do this when it splits your post on a <!–more–> tag. If you don’t want this default … Read more

Add a custom function to widget code

Where did you call your item_width_cols_to_class “function”? You are using the function as a method inside the My_Widget class. Therefore, you have to call it with a reference to its non-existent object e.g. $this->item_width_cols_to_class() or self::item_width_cols_to_class() (static).

can’t access some WordPress function from my plugin

First, since the if (!function_exists(‘check_admin_referer’)) echo “<h1>check_admin_referer not found</h1>”; code is working, then you’ve eliminated the issue being proper including of your Plugin sub-file. Second, all four of those functions are core WordPress functions, so you should never get a call to undefined function error for any of them. Can you post your relevant Plugin … Read more

Function to call either single post or category

If this is the same if/else, you can just combine into if ( is_category() || is_single() ). You don’t need to pass anything to is_category() or is_single() most of the time, unless you are looking for a category or post in particular.

Editor cannot access Theme Options

First, you used a Theme Options tutorial that is way out of date. Using such out-of-date code is going to cause you many problems. You might try this one that I wrote. But specific to your current code, your call to add_menu_page() uses the edit_themes capability, which is limited to Administrator only. You need to … Read more

Unable to use get_page_by_title() more than once per page?

get_page_by_title returns an id not content. here is an example of what I use to get content from a certain page id. call the function $page_id = get_page_by_title(‘title’); $excerpt = get_excerpt_by_id($page_id); in functions.php function get_excerpt_by_id($post_id) { global $wpdb; $query = “SELECT post_content FROM $wpdb->posts WHERE ID = $post_id LIMIT 1”; $result = $wpdb->get_results($query, ARRAY_A); return … Read more

create function to call category name and slug

You don’t need to hook the dw_get_category() function. Simply do it like this: function dw_get_category() { global $post; $categories = get_the_category($post->ID); if ( $categories ) { foreach ($categories as $category) { $dw_category_slug = $category->slug; $dw_category_name = $category->name; } } else { $dw_category_slug = ‘utopia’; } $dw_category = array(‘name’ => $dw_category_name, ‘slug’ => $dw_category_slug); return $dw_category; … Read more

Problem with custom function from jQuery slider tutorial

replace slideshow_featured_posts function from that tutorial with this: function slideshow_featured_posts() { $featured = 1; // Assuming that the name of the category ID number 1 is “Featured”. $count = 3; // How many post to be shown as slides. Ideally, it should be more than 3 posts. add_filter(‘excerpt_length’, ‘hook_excerpt_featured_length’); $Silder_query = new WP_Query(array(‘cat’ => $featured, … Read more