Register post status, exclude from searches

If it was me, I would probably just override the queries on the individual templates that you are trying to hide “ghosted” posts on. However, I can see how in some situations it would be better to override the main query. How about: function public_query_published_only($query) { if ( !$query->is_single() && !current_user_can(‘manage_options’) && !is_admin() ) { … Read more

Number format for wp_count_posts()

You can use the PHP function number_format(). function wpb_total_posts() { $total = wp_count_posts()->publish; echo number_format( $total, // your number 0, // number of decimal points ‘.’, // decimal point separator ‘,’ // thousands separator ); } Or, because you are using the default values anyway, you can shorten the function to: function wpb_total_posts() { echo … Read more

Is there a way to apply WordPress categories at the block level?

No, on a logical level applying categories to blocks is equivalent to applying categories to paragraphs and shortcodes. They can’t be coaxed into it either via a custom object taxonomy as blocks don’t have numeric unique IDs I’m not sure what problem you’re trying to solve, but this is not the solution.

How Display Posts on category

You should look at the WordPress Template Hierarchy. If you want to show an archive of your posts you create a template called archive-mahsulat.php where mahsulat is your post type. Then you can add a normal WordPress Loop to the file so it can output posts of that type. If you’re looking to create a … Read more

How to create custom boxes with text inside?

In the page editor, switch to code-editor. Now your text will be within tags… probably a <p> tag. Add css to the tag so it reads: <p style=”border: 1px solid gray”> … </p> Currently, to switch to code-editor, click the 3-dot-menu-button in the right top of the screen/window and then “Code Editor”.

Filter Custom Post Type by Category with Ajax

Nevermind, I’ve managed to solve it. For anyone interested, the problem was ‘category__in’ isn’t support by custom post types so instead needed to edit the $args array to include ‘tax_query’. $args = array( ‘post_type’ => ‘libraries’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘library_types’, ‘terms’ => $category ), ), );

count the total number of comments the user has received for his published posts

You can use the get_comments() function like so: $total = get_comments( array( ‘post_author’ => get_current_user_id(), ‘post_status’ => ‘publish’, ‘type’ => ‘comment’, ‘count’ => true, ) ); echo ‘total comments of your all posts : ‘ . $total; Just customize the arguments based on your requirements/preferences, and in the above example, I’m retrieving the total number … Read more

Automatically add custom CSS to new posts using a category template

If you have created a custom php template then add a specific class selector to your css within this template. As an example: <body class=”mycustomclass”>all your page content</body> or <content class=”mycustomclass”>all your content content</content> It doesn’t have to be on body or content or any other specific part of the page but make it encompass … Read more