Hi Waqar,
I have two custom post types for my jobportal: companies and job ad
How can I output only the companies that have a published job ad?
I have created a view, but I can't figure out how to do this.
One company can have limitless job ads, but one job ad can have only one company.
Heiko
My issue is resolved now. Thank you!
Hi again,
I have to reopen this topic.
I got the view with help of the field "Unternehmen hat mindestens eine aktive Stellanzeige". Now I try to figure out how to combine the field with the job ad and set it to 1 and back to 0 if there are no more job ads published from this company.
_____________________________________________
EDIT:
Perhaps it could be done with this two hooks, if they were well adressed?
add_action('cred_submit_complete', 'my_success_action',10,2);
function my_success_action($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==12)
{
// user can overwrite everything here, eg redirection, messages displayed etc..
// eg redirect regardless of form settings
header('location:success.php');
}
}
//Custom success action can also be performed for a specific form by using the form ID:
add_action('cred_submit_complete_12', 'success_for_form_with_id_12',10,2);
function success_for_form_with_id_12($post_id, $form_data)
{
//some code here
}
//Updating a custom field when a post expires
add_filter('cred_post_expiration_custom_actions', 'my_custom_actions', 10, 3);
function my_custom_actions($custom_actions, $post_id, $form_data) {
$custom_actions[] = array( 'meta_key' => 'advert_active', 'meta_value' =>'false' );
return $custom_actions;
}
_____________________________________________
If you have a better solution or can give me a hint for this, I'll be very thankful.
PS: I deactiviated the admin account, but will reopen it if it helps.
Hi,
Thank you for waiting, while I performed some testing on my website.
If you'd like to show only those company post in the view, which has at least 1 job post attached to them, you can wrap the view's output, inside a conditional block like this:
( ref: https://toolset.com/course-lesson/using-toolset-conditional-block/ )
Screenshot 1: hidden link
Screenshot 2: hidden link
Screenshot 3: hidden link
( ( '[wpv-post-id item='@company-job.child']' != '' ) )
Note: Please replace "company-job" with the actual post-relationship slug used on the website.
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
Hi again,
thank you for your work, but I can't get this to work and I can't find my issue.
Can you have a look?
You find the access data in the private message from 4.9.2020
Heiko
Hi,
Thanks for writing back and for granting the admin access.
I noticed that the conditional block was added with the correct condition, but it was added around the entire view block.
I've moved it inside the view's "View loop" block so that all inner blocks are wrapped inside this condition.
( screenshot: hidden link )
Next, some custom script was needed to remove the grid items for the results, where there is no content shown.
( these will be the result items which have no job ad post attached to them )
jQuery( document ).ready(function() {
jQuery('.tb-grid .tb-grid-column:not(:has(h3.tb-heading))').remove();
});
You'll find this added in the view's "Custom JS" field.
( screenshot: hidden link )
As a result, there is only one post "TESTUNTERNEHMEN 3" is showing on the "/alle-unternehmen/" page, as only that is the post with some job ad.
regards,
Waqar
My issue is resolved in a perfect way. Thank you!