Mixing variables into an array when inserting values

You are creating a string …. $sql=””ft_num”=>””.$ticket[‘number’].'”,”booking_id”=>”‘.$ticket[‘booking’].'”‘; … but expecting it to operate as an array… array( $sql, ‘event_id’ => $event[‘id’], This has nothing to do with how WordPress does anything. This is pure PHP. You have literally created this: array( [] => “ft_num”=>”‘.$ticket[‘number’].'”,”booking_id”=>”‘.$ticket[‘booking’].'”, ‘event_id’ => $event[‘id’], You need to build the array dynamically. $dynargs … Read more

Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?

Couple points: The customize_register action hook actually passes your function the $wp_customize variable, you don’t need to declare it as the global. Just put it as the first argument in your function declaration. The reason your code doesn’t run on the front end of the site is that the customize_register action hook only runs when … Read more

Changing the color scheme based on the url visited

The Misconception get_site_url() retrieves the site_url option from the database, as set under General Settings in the administrative backend / wp-admin. If this is indeed the exact same wordpress installation it will always return the same thing, regardless of whether the location is reachable via one, two or five hundred domains. You might want to … Read more

Pagination broken on is_front_page()

According to the WP_Query docs: Pagination Note: Use get_query_var(‘page’); if you want your query to work in a Page template that you’ve set as your static front page. The query variable ‘page’ also holds the pagenumber for a single paginated Post or Page that includes the Quicktag in the post content. Display posts from current … Read more

Prev/Next Links Broken on Static Front Page Pagination

previous_posts_link() echos the result of get_previous_posts_link() which checks the paged query variable, not the page query variable used on static pages. You will have to write your own code to display the link on a static page. I didn’t test it, but you might try fooling WordPress: function homepage_test() { global $paged; Now your changes … Read more

stripping tags from excerpt in WordPress is not working

the_excerpt() automatically echoes the excerpt text. What you need is get_the_excerpt(): <a href=”https://wordpress.stackexchange.com/questions/108530/<?php the_permalink() ?>” title=”<?php echo strip_tags( get_the_excerpt() ); ?>”> However, it probably won’t strip out ellipses (…) since they’re HTML entities, not tags.

Displaying posts based on category

Add category_name or cat in your arguments (args) array. <div id=”mini_stream”> <ul> <? $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 4, ‘category_name’=>’html’, ); $loop = new wp_Query($args); while($loop->have_posts()) : $loop->the_post(); echo ‘<a href=”‘.get_permalink().'”>’; echo get_the_post_thumbnail($post->ID, ‘category-thumb’); the_title( ‘<h6>’, ‘</h6>’ ); echo ‘</a>’; endwhile; wp_reset_query(); ?> </ul> </div>

Skip foreach loop

In line 195 you’re using get_categories, which can be filtered to exclude specific category numbers, either through an array of arguments, or a query string. Since $options is already set, you could add to it before you call get_categories: if ($show_assigned_categories == ‘true’ && is_single()) { $categories = get_the_category(); } else { $options[‘exclude’] = ‘1,2,3’; … Read more

Detecting if parent page has gallery

It happens because strpos returns 0 (zero index position) when gallery shortcode is at the start of the content which is treated as false by the if condition. Solution is to use Identical operator === in condition to check if the return value is a boolean false.