Shortcode to list a category of jobs

Hi, How can I add on another page the same list of jobs in a certain category.
Cant see a short code that lists a category of jobs.
Thanks

  • Ash

    Hello @yamadan

    Welcome to WPMU community!

    I hope you are well today and thanks for asking the question.

    I am afraid, there is no such shortcode. But I am marking this as a feature request.

    Also, I am tagging an available developer from second level support line in this thread for his valuable opinion on this issue. Please note that, developer response might be slower than usual staff response, so we appreciate your patience on this.

    Cheers
    Ash

  • yamadan

    We would ideally want, the full category page as is.
    But seperate pages with individual content then a feed from the specific jobs category.
    Dont want to add the link to dev site here, how do I email your support?

    Would this work and can you expand on how to get it working...

    For each job which is outputted by the Landing template or Archive template, I would like to 'tag' the div with a class which contains the name of the category it is from.

    For example, the default behaviour of your plugin adds a random colour class to the containing div of each Job (though this isn't particularly useful in any semantic sence, it just looks nice). Similarly, I would like to add a class which outputs the Category name as a class (it doesn't have to be graceful, it could simply output the pure text value of the category, or anything else which identifies it as belonging to its Category), so that it is given a class which I can then style accordingly.

    It is possible, for example, to include the ID in the generated HTML by using:

    <?php echo ($job->id); ?>
    But there doesn't exist something like:
    <?php echo ($job->category); ?>
    Is there anything you can think of to achieve this?

  • Ash

    Hello @yamadan

    You can overwrite the template file from inside of your theme. Create a file, say my-custom-job.php in your theme folder. I am attaching a version, you can use that for now.

    Then use the following code:

    add_filter( 'ig_view_file', function() {
    	return get_stylesheet_directory() . '/my-custom-job.php';
    });

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code. I assume you are using at least php 5.3+

    Note that, the file name should be same in the code above.

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

  • yamadan

    Hi Ash, thanks for the response.

    Unfortunately, your reply doesn't address the question I have in detail - I think I need to be more explicit with my query, so please let me try to explain again.

    Because there is no shortcode currently to filter jobs by category, such as...:

    [jbp-landing-page job_category="CATEGORY NAME"]

    ...I would instead like to be able to at least tag the job items, so that they are semantically distinguishable from one another. Here's how you would do it:

    /wp-content/plugins/jobs-plus/app/views/landing/main.php

    Within this file, on line 18, there is the start of the containing div which loops through all of the job items. Here it is:

    <div class="jbp_job_except <?php echo $colors[array_rand($colors)] ?>">

    What I would like to do is echo the Category name as a class here as well. Discarding the random colour class for a moment, I would imagine it would look something (though this doesn't work) like this:

    <div class="jbp_job_except <?php echo ($job->category); ?>">

    Which would output:

    <div class="jbp_job_except JOB-CATEGORY-NAME">

    This is what I need. $categories appears as a public object, but I would like to extract the selected category itself from the array. Is this possible?

    I hope that makes sense.
    Thank you.

  • Ash

    Hi @yamadan

    I understood what you mean, it's my mistake that I forgot to upload the custom file.

    This is the file you can get from here: http://pastebin.com/TWRhZCQL

    Check line no 29 and 31 - this is the way to get the category name and use as a class. But I suggested a way so that you don't need to edit the core file. Because, if you edit the core file, when you will update the plugin the changes will be lost. So, to keep your changes for landing page, try the following method. Add the following code:

    add_filter( 'ig_view_file', function( $view_path, $view ) {
    	if( $view == 'landing/main' ){
    		return get_stylesheet_directory() . '/my-custom-job.php';
    	}else{
    		return $view_path;
    	}
    }, 99, 2);

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Now create a file in your theme folder called - my-custom-job.php and add the content from here: http://pastebin.com/TWRhZCQL (you still need to match the sidebar layout from your current theme).

    This way, the plugin file remains untouched and you can change the code of landing page outside of the plugin. Again check line 29 and 31 for category implementation as class name.

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.