Not able to display category link and name [closed]

get_the_catgory() returns an array of category objects assigned to a post. You are trying to use the result as a string. If you have debugging enabled, you would have received an error regarding this. You either need to loop through the array and handle each category separately, or you can reference them directly, like get_the_category()[0] … Read more

Call function on a single page

Assuming your function runs generally, to limit it to a specific page use if( is_page( 2094 ) ) { add_filter(“sjb_job_location_filter_args”,”exclude_jobs_locations_uk”); } The location of the function definition doesn’t matter. P.S. Regarding excluding categories . . . yeah, we’d need to know a lot more about what’s going on with the called (plugin?) function

How to display a linked category name with get_the_category

get_the_category() returns the array of WP_Term objects. So, // get all categories objects $categories = get_the_category(); // get the first category name if ( ! empty( $categories ) ) { $category = $categories[0]->name; } $output .= ‘<li><a href=”https://wordpress.stackexchange.com/questions/293636/” . get_the_permalink() . “https://wordpress.stackexchange.com/questions/293636/”>’; $output .= get_the_title() . ‘</a> ‘; $output .= $category .”https://wordpress.stackexchange.com/questions/293636/”; $output .= get_the_time(‘d … Read more

How to get child category list post in one template?

get the child categories, using get_categories(); then loop through them with a foreach loop, using WP_Query() : <?php $cats = get_categories(‘child_of=”.get_query_var(“cat’)); foreach ($cats as $cat) : $args = array( ‘posts_per_page’ => 3, // max number of post per category ‘category__in’ => array($cat->term_id) ); $my_query = new WP_Query($args); if ($my_query->have_posts()) : echo ‘<h3>’.$cat->name.'</h3>’; while ($my_query->have_posts()) : … Read more

Display post content from category name using ajax

add_action( ‘wp_ajax_nopriv_load-filter’, ‘prefix_load_cat_posts’ ); add_action( ‘wp_ajax_load-filter’, ‘prefix_load_cat_posts’ ); function prefix_load_cat_posts () { global $post; $cat_id = $_POST[ ‘cat’ ]; $args = array ( ‘cat’ => $cat_id, ‘posts_per_page’ => 3, ‘order’ => ‘ASC’ ); $cat_query = new WP_Query($args); if($cat_query->have_posts()) : while($cat_query->have_posts()) : $cat_query->the_post(); $response=”<div class=”the-post”>”; $response .= ‘<h1 class=”the-title”>’; $response .= ‘<a href=”#”>’. get_the_title() .'</a>’; $response … Read more