Multidimensional Array

The multidimensional array in this case is a multi-dimensional associative array, or a key-value pair. The key being ‘status’ and the value being your array of strings. In the conditional check you have attempted to access values by a numerical index, which in this case do not exist as nothing has been set to use … Read more

Loading Posts & Category with Ajax

Sure, the get_template_part() function can be called multiple times referencing to different files, so if you have a file in the partials/-folder, all you have to do is add a second function call here. function load_cat_posts () { $cat_id = absint($_REQUEST[‘cat’]); $args = array ( ‘cat’ => $cat_id, ‘posts_per_page’ => 10, ‘order’ => ‘DESC’ ); … Read more

How to exclude a widget from W3 Total Cache Plugin

You need to use fragment caching so enable PHP in the widget and then use the following tags: <!– mfunc –> The following links should help: https://wordpress.org/support/topic/using-shortcodes-with-fragment-caching/ https://www.justinsilver.com/technology/wordpress/w3-total-cache-fragment-caching-wordpress/

Add date before entry title in Twenty Twelve

Base on @Tunji answer. You can add some conditions to the function to detect home-page, feeds… function display_extra_title( $title, $id = null ) { $date = the_date(”, ”, ”, false); if(is_home()){ $title = get_bloginfo( ‘name’ ); return $date . $title; } else{ return $date . $title; } } add_filter( ‘the_title’, ‘display_extra_title’, 10, 2 ); In … Read more

Find out last 7 days of upload images, last week uploaded image from Gallery and display them in different pages

Here I’ve written a function for you- function the_dramatist_get_post_by_time_range( $args=”” ) { $date_query = array(); if ( $args === ‘last 7 days’) { $date_query = array( ‘after’ => ‘1 week ago’ ); } else { $month_ini = new DateTime(“first day of last month”); $month_end = new DateTime(“last day of last month”); $date_query = array( array( … Read more

get db values for external js file

You need to use wp_localize_script() when you enqueue the js script. It’s usually a good alternative of ajax way and this will save you to create multiple js files. wp_localize_script() can be used to make any data available to your script that you can normally only get from the server side of WordPress. As you … Read more

How do I access post_meta key with php?

According to docs (https://developer.wordpress.org/reference/functions/get_post_meta/), it should be something like: <?php if(!get_post_meta(get_the_ID(), ‘buy_status’, true)): ?> display: block; <?php else: ?> display: none; <?php endif; ?>

Else/If Statement to Display Photo Descriptions

How about like this: <div style=”position: relative”> <?php the_post_thumbnail(‘large’); $imagedesc = get_post(get_post_thumbnail_id())->post_content; if(!empty($imagedesc)) { echo ‘<span style=”position:absolute; bottom:9px; right:0; color:#FFF; background:rgba(0,0,0,0.8); padding:4px 6px; font-size:0.7em”>’; echo $imagedesc; echo ‘</span>’; } ?> </div>

How to hide the author box of a specific user?

If you know the data of the author, you can wrap that box with an if and the function get_the_author if( get_the_author() == “name_of_the_author” ){ // Don’t do it }else{ // Print box } EDIT with the final answer updated: <?php echo $td_mod_single->get_social_sharing_bottom();?> <?php echo $td_mod_single->get_next_prev_posts();?> <?php $user = get_user_by(“login”, “pknn”); // user object // … Read more

How do I properly code my footer? See example

you can use this code in the footer … <div class=”your-class-name”> <?php _e(‘Copyright &copy ‘, ‘textdomain’); ?> <?php echo date(‘Y’); ?> | <?php _e(‘Made by Dev ‘, ‘textdomain’); ?>| <a href=”#”><?php _e(‘Privacy Policy Terms of Use’, ‘textdomain’); ?></a> </div>