Warning: Attempt to read property “ID” on null in D:\xampp\htdocs\yba\wp-content\themes\young-brand-child\functions.php on line 162 [closed]

I’m guessing the problem is here: $pg_name = apply_filters( ‘the_title’, $item->title, $item->ID ); $page_id = get_page_by_title( $pg_name ); $item_output .= ‘<a’. $attributes .’ id=”‘.$page_id->ID.'”>’; I don’t think this makes any sense: you have the item title and ID you’re filtering the title and then you’re trying to look up the page ID again by the … Read more

Strip tags from a the terms() function

You could use a filter and strip_tags(), as you suggested. Example using post tags, since that’s the taxonomy I had available: function my_remove_links( $term_links ) { return array_map(‘strip_tags’, $term_links); } add_filter(‘term_links-post_tag’, ‘my_remove_links’); Really though, I would just get_the_terms() and and craft the output yourself: function the_simple_terms() { global $post; $terms = get_the_terms($post->ID,’post_tag’,”,’, ‘,”); $terms = … Read more

Check if variable is set in filter

The variable you have named $query is actually the WP_Query instance having filters applied to it. You can simply call its function get to retrieve query vars. For example: function votes( $where, $query ) { $sort = $query->get(‘sort’); if (!empty($sort) $where .= ” AND $sort >= votes”; return $where; }

How to list posts from a plugin taxonomy?

To query by taxonomy you need to know its query_var that is used in its register_taxonomy() call. It defaults to taxonomy name so usually equal to that. Then you use that info in query argument: query_posts( array( ‘query_var’ => ‘term’ ) ); See Querying by taxonomy in Codex. It is hard to suggest more without … Read more

Translate wordpress date from Italian to English

I do this with the One Backend Language plugin. This way, the WPLANG language is only used in the frontend, and another used in the admin area. There are more plugins that do this, some allow you to choose a language per user. The downside is that you can still be logged in when you … Read more

PHP nested If statement syntax

you can’t run code inside quote since php treats it as string, try this: <?php $newsposts = new WP_Query(‘cat=restaurant’); if ( is_front_page()) { echo ‘<h3 class=”member-review”>Latest Restaurants</h3> <div id=”extra”>’; if ($newsposts->have_posts()) : while ($newsposts->have_posts()) : $newsposts->the_post(); echo ‘<div class=”reslogo”><img src=”‘.catch_that_image().'”/></div>’; endwhile, endif; echo ‘</div>’; } ?>