Change the default number of posts to show on mobile version

Firstly, you need to detect mobile devices, probably the easiest and a built in possibility is wp_is_mobile. It is simpler then other solutions that are available, but works reasonably well. It can be altered, if necessary, take a look at this question for a first insight into that. Secondly, if that concerns your main query, … Read more

WP_Query to work with custom view

Use a custom view in the front-end: You can try to modify the SELECT queries in the front-end with the following (alpha) plugin: <?php /** * Plugin Name: wpdb – a custom SELECT view for the wp_posts table on the front-end * Version: alpha */ ! is_admin() && add_filter( ‘query’, function( $query ) { global … Read more

Query posts distinct authors

With what you are asking, it is really difficult to come up with some performant easy way that is also reliable. As @birgire already stated, his solution is not reliable, but from tests, it seem to be the fastest clocking in at 2 db queries in about 0.015s average. From a quick discussion between @birgire … Read more

Updating a post without escaping ampersands?

That is correct, the updating in the Admin section does not change the & to &amp; while the wp_update_post() function (which can be found under /wp-includes/post.php on line 3772) does but only when the user does not have the capability unfiltered_html, let me explain how I found this out, and what I recommend. I did … Read more

Categories box not showing on post edit pages

For all who have the problem just with WordPress Blocks/Gutenberg, here is the solution I was looking for a long time. When you create a new taxonomy, make sure you’ve set show_in_rest to true. Otherwise it will not appear in Block editor. https://developer.wordpress.org/reference/functions/register_taxonomy/ Whether to include the taxonomy in the REST API. Set this to … Read more

how to get permalink using sql

I am not sure why you are using a custom query and not get_posts() or WP_Query as you should. Anyway, you need to get the post ID … $query =”SELECT wp_posts.post_title AS title , wp_posts.post_content AS content, wp_posts.post_date AS blogdate , wp_posts.ID AS ID And then just pass this ID to get_permalink(): get_permalink( $post->ID ); … Read more

Create posts without login from frontend

You should not allow anonymous users to publish anything on your website without authentication. If you need to store custom data that is specified by users, you should use the custom fields instead. In your case, add_post_meta() comes in handy. After creating a post using wp_insert_post(), pass its ID to add_post_meta() and add custom fields … Read more

upload image in a meta box

You may want to take a look at Steve Taylors plugin and his approach here Dominik “ocean90” Schilling – the author of the (new in 3.5) media library, has a GitHub repository where he shows off some demos. In short, you might not be able to implement a drag&drop style media uploader in a meta … Read more

How to Load Scripts and CSS for Admins Only When Editing or Adding Posts

you want to use admin_print_scripts-(page_hook) and admin_print_styles-(page_hook), so in your case: add_action(‘admin_print_scripts-post.php’, ‘call_my_function’); add_action(‘admin_print_scripts-post-new.php’, ‘call_my_function’); add_action(‘admin_print_styles-post.php’, ‘call_my_styles_function’); add_action(‘admin_print_styles-post-new.php’, ‘call_my_styles_function’);

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