exclude certain categories from posts
exclude in get_posts() refers to post IDs, they are not interchangeable with category IDs. The argument you are looking for is probably ‘category__not_in’ => [ 8 ]
exclude in get_posts() refers to post IDs, they are not interchangeable with category IDs. The argument you are looking for is probably ‘category__not_in’ => [ 8 ]
You can use ‘the_title’ filter (Codex link) add_filter( ‘the_title’, ‘lose_four_chars’); function lose_four_chars($title) { if ( is_single()) { return substr($title, 4); } else { return $title; } }
Put something along these lines in your functions.php: add_filter( ‘pre_get_posts’, ‘custom_get_posts’ ); function custom_get_posts( $query ) { if( is_category() || is_archive() ) { $query->query_vars[‘orderby’] = ‘name’; $query->query_vars[‘order’] = ‘ASC’; } return $query; } reference here (see the second answer)
<p> <?php the_time() ?> </p> It helps with separation of concerns and increases readability of code as well as being consistent with WordPress coding standards and the default coding style. The first method you attempted is completely invalid, the_time() only accepts 1 parameter, the date format. The second method has roots in validity, but the_time() … Read more
Your code doesn’t seem to be trying to hide the content, but you can use the_content filter to return an empty content if you are on a specific post page. For example: add_filter(‘the_content’, ‘hide_post_contents’); function hide_post_contents( $content ) { if( is_single(3) ) { return ”; } return $content; } Also, there is a mistype in … Read more
Just use the Page-ID class e.g. 123 and use plugin like Custom CSS. There you do: .page-id-123 { font-size: 100px; } You may need to add a class as well if you want to style a certain object.
If in doubt, check the documentation first: https://www.advancedcustomfields.com/resources/get_field/ Check if value exists This example shows how to check if a value exists for a field. $value = get_field( ‘text_field’ ); if ( $value ) { echo $value; } else { echo ’empty’; } So, in for your case you would need to use: <?php $short_testimonial … Read more
I have sorted this issue i was tested this code on our test server and i saw error on post detail page the error was Fatal error: Call to undefined function short_title() after seen this i have remove the function code short_title(); from my custom.php and replace with the_title(); to display tittle.And i have check … Read more
Just set the permalink to numeric ( Under Setting -> Permalinks ). This works for me.
after days of research, I found that the fault was simply in the pagination. By changing the pagination code, I have made it work. <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $custom_args = array( ‘post_type’ => ‘veranstaltungen’, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘paged’ => $paged, ‘posts_per_page’ => ’10’ ); $wp_query = new WP_Query($custom_args); … Read more