Problem to filter articles
-
Hello,
I have a website where WP Job Manager is installed to show job offers, recently we wanted to sync our job board on WordPress with our Jobaffinity which is a service that publishes job offers on different websites for you.
For this to happen, we created a user in our wordpress for Jobaffinity that can publish articles.
What we need to do is create a template that loops on Articles and selects only the ones posted by Jobaffinity to show them on WP Job Manager, problem is that we don’t know what post_type to put in our code, and if in the end WP Job Manager posts are considered as article or not?
Here is the code we put in our template:
<?php /* * Template Name: Jobaffinity Job Listings */ get_header(); // Remplacez '293' par l'ID réel de l'utilisateur Jobaffinity, si nécessaire. $author_id = '293'; // Préparez la requête pour les offres d'emploi $args = array( 'post_type' => 'job_application', // Spécifiez le type de publication personnalisé de WP Job Manager 'author' => $author_id, // Filtre par ID d'auteur, si nécessaire 'posts_per_page' => -1 // -1 pour afficher tous les posts. Ajustez selon le besoin. ); $job_query = new WP_Query($args); if ($job_query->have_posts()) : while ($job_query->have_posts()) : $job_query->the_post(); // Affichez ici le contenu de chaque offre d'emploi // Par exemple, le titre et un lien vers l'offre complète echo '<h2><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>'; the_excerpt(); // Affiche un extrait de l'offre d'emploi endwhile; else : echo '<p>Aucune offre d\'emploi trouvée.</p>'; endif; // Réinitialiser les données de la requête wp_reset_postdata(); get_footer(); ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Problem to filter articles’ is closed to new replies.