Reworking function for counting custom post type posts count

You have a couple of problems with your code customtaxonomy=$mytaxonomy is incorrect. First of all, there is no parameter called customtaxonomy in get_posts. Secondly, your syntaxing is wrong. If you make use of a varaible, your syntaxing should look like this ‘post_type=myposttype&customtaxonomy=’ . $mytaxonomy . ‘&posts_per_page=-1’ You should make use of a proper tax_query to … Read more

Show excerpt if no title in admin view

You can try the following approach using the the_title filter in the edit.php screen: /** * Modify post titles in the edit.php screen. * If the post title is empty, then show max 10 words from the post content instead. */ add_action( ‘load-edit.php’, function() { add_filter( ‘the_title’, function( $title ) { $post = get_post(); if( … Read more

Memory issue with get_posts( ) function

Running a no limit query is very likely the cause of your memory issues. So you might want to change your query. If still you need to do this way, you can use the fields option, it returns post IDs only and will save a lot of memory usage – example below: $your_query = get_posts( … Read more

How can I use wordpress functionality outside of WP framework

It’s just simple, same reply from Error in WP_update_post but in your case there is small change. Just use wp-load.php as include. No need to include post.php. Once the wp-load.php file is included, the entire wealth of WordPress functions is provided to you. For pull the recent post, you need to use wp_get_recent_posts() wordpress function … Read more

get posts that doesn’t contain a specific tag

You could try the tax_query with the ‘NOT IN’ operator (untested) $myposts = get_posts( [ ‘tax_query’ => [ [ ‘taxonomy’ => ‘post_tag’, ‘terms’ => [ ‘index’ ], ‘field’ => ‘slug’, ‘operator’ => ‘NOT IN’, ] ] ] ); where the taxonomy slug for tags is post_tag.

How to get posts from a current post’s month?

There is date_query which can handle this and an SQL query is not a good practice when you can take advantage of WordPress Query API: $pid = 1; // post ID here $args = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘post’, ‘date_query’ => array( array( ‘year’ => get_the_date(‘Y’, $pid), ‘month’ => get_the_date(‘m’, $pid) ), ), … Read more

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