Display an image based on field value

How about this? <?php $meta = get_post_meta( get_the_ID(), ‘region’, true ); if ($meta == ‘NA’) { ?> <img src=”https://www.esrnetwork.com/wp-content/uploads/2016/12/NA.png” width=”25″ height=”25″/> <?php } elseif ($meta == ‘EU’) { ?> <img src=”https://www.esrnetwork.com/wp-content/uploads/2016/12/EU.png” width=”25″ height=”25″/> <?php } else { } ?>

How can I split my query result in 2 arrays?

There’s no need to split the array, you can just close the first div once you’ve counted up to four elements of the array. $args = array( ‘post_type’ => ‘event’, ‘meta_key’ => ‘date’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’, ‘posts_per_page’ => 8, ‘meta_query’ => array( ‘key’ => ‘date’, ‘value’ => date(‘Y-m-d’,strtotime(“today”)), ‘compare’ => ‘>=’, ‘type’ … Read more

Concatenate Custom Field Value & HTML Value

To display the_meta () after the ‘by author for’ text just needs a small change: <p style=”text-align:left;font-size:18px;margin-bottom:5px;”><span style=”color: #000000;”>By AUTHOR FOR</span> <?php the_meta (); ?></p> However I’m not sure you want to use the_meta (), because all values get displayed, and in an unordered list. (Reference: the_meta.) Instead you probably want get_post_meta, so: <p style=”text-align:left;font-size:18px;margin-bottom:5px;”><span … Read more

PHP Redirect condition

If you want it to run as early as possible, which makes sense if you want to avoid loading unnecessary assets, put the code in a function in a Must Use Plugin, and hook that function to the muplugins_loaded action. <?php add_action( ‘muplugins_loaded’, ‘wpd_my_redirector’ ); function wpd_my_redirector() { // your code here // wp_redirect is … Read more

Posts are not looping through correctly

I just tested the following example code: <?php $the_query = new WP_Query( array( ‘posts_per_page’ => 12, ‘paged’ => get_query_var(‘paged’, 1) )); if ( $the_query->have_posts() ) { // display #ajax wrapper only if we have posts echo ‘<div id=”ajax”>’; while($the_query->have_posts()) { $the_query->the_post(); ?> <article <?php post_class(); ?>> <div class=”row”> <div class=”col-md-4″><?php the_post_thumbnail(‘medium-thumbnail’); ?> <h2><a class=”post-title” href=”https://wordpress.stackexchange.com/questions/252035/<?php … Read more

call_user_func_array() expects parameter 1 to be a valid callback, function ‘———-‘ not found or invalid function name

Like your previous questions answer if you have called any class method you need to reference the class. So you need to replace this line $theme_options = $mafongroup_menu_page_creation_method( $page_title, $menu_title, $capability, $menu_slug, $function,’dashicons-image-filter’, ‘2.111111’); With this one- $theme_options = $mafongroup_menu_page_creation_method( $page_title, $menu_title, $capability, $menu_slug, array( $this, $function ),’dashicons-image-filter’, ‘2.111111’); So your above code will be … Read more

Images Uploaded saving onto older/previous year folders

You should check yourself what you get when you execute wp_upload_dir. Typically you run this code: $d = wp_upload_dir(); print_r( $d ); wp_die(); And the reply needs to be like this in 2017/01 Array ( [path] => /var/www/html/test100.com/wp-content/uploads/2017/01 [url] => http://test100.com/wp-content/uploads/2017/01 [subdir] => /2017/01 [basedir] => /var/www/html/test100.com/wp-content/uploads [baseurl] => http://test100.com/wp-content/uploads [error] => ) You will … Read more

Infinite Loop – WP_Query

Your second loop, the $ticketQuery loop is missing $ticketQuery->the_post(). The function the_post() actually sets up things like template tags, the $post object. The most important thing it does is increments the post counter so that eventually $ticketQuery->have_posts() will eventually return false. Without the_post() is your infinite loop.

Split shortcodes to array of shortcodes

WordPress already has built in support for Nested Shortcodesprovided their handler functions support it by recursively calling. So if you have for example: [tag-a] [tag-b] [tag-c] [/tag-b] [/tag-a] As long as you recursively call do_shortcode in your shortcode function, all the shortcodes would be parsed. So you would define the functions for your shortcodes as … Read more