Echoing a CSS class based on category of post in a list

get_category(’91’) is always going to return an object of category ID 91’s data. This means your if statement is always going to return as true. You need to get the current iterated posts assigned category ID and then check if it is 91. <!– Return objects of current iterated posts associated categories –> $categories = … Read more

Can’t get url_to_postid to work

Probably because you don’t have a colon in the url after https (assuming you copied the $url parameter correctly). The function will return a ‘0’ if the page does not exist.

How to add page numbering with php?

to change the number of ‘posts_per_page’ for one specific category archive page (assuming your are using a different number for all other archives), try working with the ‘pre_get_posts’ action; see https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts assuming that your category template is for the ‘video’ category, the code to be added into functions.php of your (child) theme, could be, for … Read more

export a mysql table to csv with column headers

You should build Your columns schemat in array. Than add this on the top of csv and than You can add content of Your csv. $string_headers=”post_title,post_author,etc….”; if(count($results) > 0) { $result = $string_header; foreach($results as $result){ $tmp_result = array_values($result); $result .= implode(“, “, $tmp_result); $csv_output .= $result.”\n”; }

Where to copy woocommerce files to in my custom theme to avoid editing the core plugin?

To override WooCommerce (WC) templates, put your modified templates in custom_theme/woocommerce/template-category/template-name.php Example: To override the admin order notification, copy: wp-content/plugins/woocommerce/templates/emails/admin-new-order.php to wp-content/themes/yourtheme/woocommerce/emails/admin-new-order.php WC Documentation Reference

get_comments_number() returns 0

From quick look at the source there seems to be three possibilities: get_post() returned falsy value, so current post context is invalid in some way. $post->comment_count is 0. get_comments_number filter is being used to adjust the output. Most commonly it would be case 1/2 with something interfering with global post context, dump get_post() at the … Read more

What’s wrong with this piece of code? [closed]

This loop: while($listing->have_posts()): get_template_part( ‘partials/listing-cars/listing-list’, ‘loop’ ); endwhile; will never terminate, because $listing->have_posts() will never be false. You need $listing->the_post() to advance the loop to the next post in each iteration. Then, when the last post is reached, $listing->have_posts() will be false and the loop will end. while($listing->have_posts()): $listing->the_post(); get_template_part( ‘partials/listing-cars/listing-list’, ‘loop’ ); endwhile;

Known Issues in WordPress When Upgrading PHP to ver 7

WordPress recommends PHP7 and MariaDB 10.0 or higher, so your core installation should be fine. If you’re using any third-party plugins and/or themes (including ones you’ve written), you would be wise to ensure that they too are compatible with PHP7. Check the respective maintainers’ support streams (either the relevant plugin/theme pages on wordpress.org or the … Read more