Display a list of posts corresponding to a category

As an alternative, consider using get_posts()? get_posts() It will require other changes to your code but you can easily create a query to include Categories, and then foreach through the results. Update: Here’s an equivalent to your code written with get_posts(). Take a copy of your own code first but the below would replace it … Read more

Accessing WordPress Functions get_permalink() in Vanilla PHP?

The developer’s reference is a great place to start. You’ll find get_permalink in wp-includes/link-template.php. You might want to look into wp-cli wp post list –post__in=1 –field=url should do the trick as discussed in wp-cli issue#2727 Also, there’s the rest-api to consider. The best solution for getting the permalink might be to just post/cURL a request … Read more

Remove /category/ from category (archive) page URLs (without using a plugin)

Please add this code in functions.php to remove the “category” text from permalink. function remove_category( $string, $type ) { if ( $type != ‘single’ && $type == ‘category’ && ( strpos( $string, ‘category’ ) !== false ) ){ $url_without_category = str_replace( “/category/”, “/”, $string ); return trailingslashit( $url_without_category ); } return $string; } add_filter( ‘user_trailingslashit’, … Read more

how to import contacts from php to wordpress

By default, when adding a new user using either wp_create_user() (https://developer.wordpress.org/reference/functions/wp_create_user/) or wp_insert_user() (https://developer.wordpress.org/reference/functions/wp_insert_user/) the password is passed in as a plain-text string, and the WP functions will encrypt into the wp_users table. There are some plugins out there that will allow import from a CSV (example: https://wordpress.org/plugins/import-users-from-csv/) If you are looking at writing your … Read more

how to convert wordpress query to pdo query

I just found my answer “SELECT post_title ,post_date, display_name ,wp_users.ID, wp_users.display_name as user_nicename, COUNT(*) as count FROM wp_posts, wp_users, wp_term_relationships WHERE wp_posts.post_type=”post” AND wp_posts.post_status=”publish” AND wp_posts.post_author = wp_users.ID AND wp_posts.ID = wp_term_relationships.object_id AND wp_term_relationships.term_taxonomy_id = ’10’ GROUP BY post_author ORDER BY count DESC LIMIT 5 ;”

how to add display_name

Is this the same situation you are also asking in how to add display_name from the users table to this query – yes? You can see my answer there.

php-page with db connection

This file to access WordPress default functions has to be inside the WordPress folder. It’s the best practice to create a plugin if you want to add custom features. WordPress provide directory path and URL’s functions with which you can get the path of any specific file. Please visit the following links to understand how … Read more

Why not showing all post by default in my jquery filter

@HappyArif You just kept a line in your code that needs to be changed if there is a Category selected. $args = array( ‘orderby’ => ‘date’, ‘post_type’ => ‘course’, ‘posts_per_page’ => -1, ‘tax_query’ => $tax_query, ); This have ‘posts_per_page’ => -1 which needs to be changed to ‘posts_per_page’ => 9, ‘paged’ => $paged to make … Read more