Problem: After two days have passed from the time of post creation, I would like to display some text on my post that says the post has expired.
Solution: Use two separate custom date fields to store the post creation timestamp and the post expiration timestamp. Use a custom function or custom shortcode to compare the expiration timestamp with the current timestamp. The following code example shows how to set the two requested custom field values:
//FECHA AUTOMÁTICA BONOS
add_action( 'save_post', 'tssupp_auto_set_date_fields', 100, 3 );
function tssupp_auto_set_date_fields( $bonos, $post, $update ) {
$post_type = 'bonos';
$created_field_slug = 'fecha-de-creacion-del-bono'; // edit your created field slug here
$expiration_field_slug = 'fecha-de-caducidad'; // edit your expiration field slug here
// do not edit below this line
$created_field_value = get_post_meta($bonos, 'wpcf-' . $created_field_slug, true);
$expiration_field_value = get_post_meta($bonos, 'wpcf-' . $expiration_field_slug, true);
if ( $post->post_status == 'publish' && $post->post_type == $post_type && !$created_field_value ) {
update_post_meta( $bonos, 'wpcf-' . $created_field_slug, date('U') );
}
if ( $post->post_status == 'publish' && $post->post_type == $post_type && !$expiration_field_value ) {
update_post_meta( $bonos, 'wpcf-' . $expiration_field_slug, (date('U') + 172800) );
}
}
Problem:
have a view of a relationship between platform and resources.
In this view, I would like to add a cred_child_link_form to add a user review to "platform" (platform is the parent of the relationship).
If I understand it correctly, I need to add the id of the parent of the relationship (the platform) to the parameter "parent_id" to make it work? Is it possible to do this, or do I need a custom code?
Problem:
The user was not able to add an edit link. He needs to choose a layout, and he was not able to choose the correct layout.
Solution:
It turns out that the user was trying to select a layout that was also assigned to the custom post type.
The edit layout should not be assigned.
Problem: I am using a custom post type Profiles to create custom Profile posts for Users. I have a Form that is used to create these posts on the front-end of the site. I have a page where I would like to display the Form if no Profile post has been created yet. If the Profile has already been created, I would like to hide the Form on the page. I also have another page where I would like to display a link to the page containing the Form. That link should also be hidden if the Profile post has already been created. This tutorial shows how to achieve this in the legacy Views editor, but not in the Blocks editor: https://toolset.com/documentation/legacy-features/views-plugin/how-to-create-custom-searches-and-relationships-for-users/#how-do-i-prevent-users-from-creating-more-than-one-contractor-post
Solution: Use the "No items found text" editor in the Loop Template configurations of the View Loop block to insert the Form or link using a shortcode, or insert a Blocks-designed Content Template containing the Form or link using a shortcode.