loop in single.php of the same category

I suggest the following: $categories = get_the_category(); $category_ids = wp_list_pluck( $categories, ‘term_id’ ); $args = [ ‘numberposts’ => 4, ‘category__in’ => $category_ids, ]; $related_posts = get_posts( $args ); $related_posts = wp_list_filter( $related_posts, [ ‘ID’ => get_queried_oject_id() ], ‘NOT’ ); if ( count( $related_posts > 3 ) ) { array_pop( $related_posts ); } global $post; foreach … Read more

Shortcode and get_template_part

Function get_template_part() load file only from theme directory (or child theme). There is no filter or action hook that would change this behavior. You will need to write your own get_template_part() variant to load files from the plugin directory (replace the locate_template() call from the original function). Or write an explicit: $query->the_post(); include plugin_dir_path( __FILE__ … Read more

        out of nowhere

Sometimes there can be space characters before the <?php at the top of the file. Or space characters after a closing ?> at the end of the file. The closing ?> is not needed in PHP files. But anything before the opening <?php, or after the not-needed ?> closing will get rendered on the page.

How can I write slugs / permalinks as: custom post type -> custom taxonomy and custom post type -> custom taxonomy (one CPT and many taxo)?

Thanks to Sally CJ, here is the solution that worked for me : /*To create new custom taxonomy */ function si0b_ct_year() { /* Property Type */ $labels = array( ‘name’ => _x(‘Years’, ‘Taxonomy General Name’, ‘siobanone’), ‘singular_name’ => _x(‘Year’, ‘Taxonomy Singular Name’, ‘siobanone’) ); $rewrite = array( ‘slug’ => ‘artistes’, ‘with_front’ => false, ‘hierarchical’ => … Read more

My single.php page skips the first div tag

While it is not officially answered the question, it is a suggested debugging technique for future audience to see how to resolve the related problem: If you ever meet such situation. Then most likely there is some tag(s) is(are) missing creating such cascading effect. So could try to hide the content output first to see … Read more

Two different single.php depending on source page

You would use page templates to accomplish what you’re doing. If you specify a page-{slug}.php, it’ll use that one instead. It always does upward traversal. So if there’s a specific page, it’ll use it. If not, it’ll be one level more general. Copy the home.php PHP into your new one, and remove the calls for … Read more

custom post type – project link output via single-portfolio.php

You can always use WordPress Code Reference to understand what is going on: get_post_custom() is a function that retrieves post meta fields and needs a post id as an parameter. It returns an array with post meta for the given post: https://developer.wordpress.org/reference/functions/get_post_custom/ get_post_custom_values() is a function that retrieves values for a custom post field and … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)