How to sort Custom Fields by a value

If you need sorted result by default,you need to query with sort parameters see https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters more more (example from the codes) $query = new WP_Query( array ( ‘post_type’ => ‘product’, ‘orderby’ => ‘meta_value’, ‘meta_key’ => ‘price’ ) ); Alternatively, you could also easily do the sorting using jquery plugins like tinysort ( see http://tinysort.sjeiti.com/ ) … Read more

Caching for logged in user and Ajax update

There are plugins that can help you with this, but they aren’t foolproof. My suggestion is W3 Total Cache, you should be able to exclude necessary files from the cache from there. Your best solution, however is to do caching on the serverside level as you will see better performance that way.

wp_query select if have comments

You might try this: add_filter( ‘posts_where’, ‘filter_where’ ); $query = new WP_Query($args); remove_filter( ‘posts_where’, ‘filter_where’ ); where function filter_where( $where=”” ) { $where .= ” AND comment_count > 0 “; return $where; } to get posts with comments.

Converting Static HTML pages to WordPress

Do you have this code corresponding to the style.css file that is in your main theme folder? <link rel=”stylesheet” href=”https://wordpress.stackexchange.com/questions/94194/<?php bloginfo(“stylesheet_url’); ?>” /> If you want to link to another name other than style.css or you have a different path you would want to use: <link rel=”stylesheet” href=”https://wordpress.stackexchange.com/questions/94194/<?php bloginfo(“template_directory’); ?>/pathocss.css”>

Display categories and their IDs

Are you looking for a list of the current post’s categories and parents, or just a general list of categories? If the former, you can use get_category_parents(). If you’re in The Loop, for example: <?php if( have_posts() ) : while( have_posts() ) : the_post(); // Post stuff // … $cats = wp_get_post_categories( $post->ID ); foreach( … Read more

Outputting the blogposts or the_content()

Post content is stored as a single block of data in the *_posts table in the post_content column. It isn’t divided up into sections, so what you want is tricky at best. What the the_content functions does is take that block of data from the database, runs one or more filters on it that alter … Read more

Problem with executing a function on saving a post

The action save_post is also called during AJAX auto-save requests. But your value is not sent then, so you save an empty value for something that isn’t set. Start your save function with: if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) return; See basic examples with more checks here and here.