How to add portfolio category post count in main navigation menu?
How to add portfolio category post count in main navigation menu?
How to add portfolio category post count in main navigation menu?
Here are some optimization suggestions for the code: Refactor the code structure: Currently, the code is using multiple if statements to determine which template to display for each portfolio item. This can be refactored to use a single switch statement. This will make the code more readable and easier to maintain. Remove redundant code: The … Read more
You can give a try to this within a loop <?php echo $wp_query->found_posts – $wp_query->current_post ; ?> $wp_query->found_posts gives the total number of posts found matching the current query parameters. So the if there are 20 posts, result for each post should look like this For 1st post it will display 20, i.e. 20-0=20 For … Read more
Word count for all posts of all authors
Using @pascalvgemert’s suggestion as a starting point, I’m using the following script: jQuery(document).ready(function() { var imgCount = jQuery(“.single-post #content-left p a”).children(“img”).length; if (imgCount == 1) { jQuery(“img”).addClass(“lone-image”); } }); Works like a charm.
You will need a function to get all the published posts and count the words. function wpse410818_count_published_words() { $posts = new WP_Query(array( ‘post_type’ => array( ‘post’ ), ‘post_status’ => ‘publish’, )); $count = 0; //Starting words count if ( $posts->have_posts() ) { while ( $posts->have_posts() ) { $posts->the_post(); //Add to the word count $count += … Read more
Background Gating unauthenticated end-user’s ability to view site content based on the activity of such users is a difficult problem to solve reliably, owed to the design of web technologies as a whole. To the best of my knowledge, WordPress core provides no features which require any such functionality, and so there are no core … Read more
I’ve run into this a couple of times with plugin content. It seems like the document ready event is fired while dynamic content is still being loaded. The way to check is to leave the Javascript where it is and load the page. When the page is fully loaded, get to your browser console (right … Read more
Using a query could give you easier customization without having to use SQL directly. $posts = get_posts( array( ‘post_type’ => ‘post’, ‘post_status’ => ‘any’, ‘numberposts’ => -1, ‘fields’ => ‘ids’, )); $total_count = count( $posts ); print_r ( $total_count );
The code requires at least PHP 5.3. Dreamweaver does not support that PHP version, so it reports unknown, newer syntax as errors. WordPress requires just version 5.2.4, but it recommends at least 5.4. My suggestion is to use always the latest stable version on the server, currently PHP 5.6. Your development setup should use exactly … Read more