Skip Navigation

[Closed] How can I migrate my categorized content into different types of new posts(types

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Tagged: 

This topic contains 14 replies, has 2 voices.

Last updated by Beda 6 years, 2 months ago.

Assigned support staff: Beda.

Author
Posts
#299888

How can I migrate my categorized content into different types of new posts(types)?
We are talking about 6000 pages so I am looking for an automated solution.
Also content includes html code which doesnt work with any csv exporters that I could find.

Thank you

#300123

Thank you for contacting us here in the Support Forum

This is not a feature that Toolset Plugins provide.

Let me specify this:

- Consider a site ( WP site ) where some Custom Post Types were created using Types, and already some content has been added to those post types.
- Using the built in feature (Import / Export) of Types Plugin, you could migrate the settings and all information related to the CPT's.
- But for the content you would need to use for example WordPress importer/exporter.

This only applies if the previous (existing) CPT's have been created with Types.
Otherwise, you can not import CPT's settings and information with Types.

It seems that you need custom programming work which is beyond the scope of our support.

At this point I would suggest you consider contacting one of our certified partners from this link:
https://toolset.com/consultant/

You will get the custom assistance you need to get on with your project.

I apologize I can't provide you a out of the box solution for this.

Please let me know if you have further questions regarding the issue mentioned in this Thread

Thank you

#300635

Thanks for your interest; rather than working with a developer, I decided to develop my own solution and started with creating custom fields for my posts. I already categorized posts so I have their own relations and links in between. What I need was a filtering mechanism.

Seems like views are promising on this topic. So here comes:

[wpv-if strfield="birth" evaluate="$strfield->format('M j') = TODAY()->format('M j')"]
Will this work or what will work to use my birth custom field to filter my all talents and get only day and month to check if its their birthday today?

Below is my full code so far for view:

<wpv-loop wrap="1" pad="true">
[wpv-if strfield="birth" evaluate="$strfield->format('M j') = TODAY()->format('M j')"]
[wpv-item index=1]
<div class="row ">
<div class="col-sm-12">
[wpv-post-featured-image]
[wpv-post-title]
[types field="birth" style="text" format="M j, Y"][/types]
</div>
</div>
[wpv-item index=other]
<div class="col-sm-12">
[wpv-post-featured-image]
[wpv-post-title]
[types field="birth" style="text" format="M j, Y"][/types]
</div>
[wpv-item index=pad]
<div class="col-sm-12"></div>
[wpv-item index=pad-last]
<div class="col-sm-12"></div>
</div>
[/wpv-if]
</wpv-loop>

Thanks

#300806

Thanks for the Details

Views (wpv-if) does only support the Operators, actions and symbols listed here:
https://toolset.com/documentation/views-shortcodes/#wpv-if

What you could do is evaluating results of a custom function:

[wpv-if evaluate="my_func() = 'aloha'"]The function returns 'aloha'[/wpv-if]

https://toolset.com/documentation/user-guides/conditional-html-output-in-views/#using-custom-functions
You would need to write a Custom Function that does provide the needed output to evaluate with the wpv-if short code.

Please also acknowledge that if you evaluate a value of a Custom Field, you would need to pass the name of the Custom field with a wpcf-prefix, as mentioned here:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/#faq

Without a Custom function, the only possibility you would have, is to evaluate for a "value", like in this different examples listed here:
https://toolset.com/documentation/views-shortcodes/#wpv-if

Please let me know if you have further questions regarding the issue mentioned in this Thread

Thank you

#300825

Thanks for all the info; I changed my code to use a function but still I need to concat or format my custom field into a day and month only form as I need to compare it with todays day to see if it is their birthday or not. How can I filter my custom field into format('M j').

I have to compare and format two sides of evaluation. Have no idea how to format my custom content into a comparable format?

#301179

Thanks for the Details

The problem is, a wpv-if evaluation does not accept a parameter such as TODAY to evaluate a certain DATE coming from the Custom Field

This you could do by filtering (query Filter) your Custom Field with a filter that checks if the Custom Field Date is == TODAY, and then loop output all the according content where this filter returns true.
(if using Views without customizing the function)

This is of course a different approach, as you would then list only the content wehre that Custom Field Filter returns true.

Going with the wpv-if evaluation and custom function, you should try to build a function as the example below, and then evaluate true or false in the wpv-if short code.

Example function:

function test() { 
    if (date = today) {
        return true
    } else {
        return false
}

You could then evaluate if your function returns true, and if yes, output your desired content with the the wpv-if short code.

Please let me know if you have further questions regarding the issue mentioned in this Thread
and let me know if the above solution works for you, I look forward to your reply!

Thank you

#301262

Hi; thanks for your help; I am just unsure what kind of output my custom field gives when I send it into function.
Below code doesnt work and I will send two tries I had. As of my lacking knowledge of PHP I might doing something wrong but this is supposed to work right?

<wpv-loop>
[wpv-if arg_1="wpcf-birth" evaluate="getTodaysDate($arg_1) = 1"]
[wpv-post-title]
[wpv-post-featured-image]
[types field="birth" style="text" format="M j, Y"][/types]
[/wpv-if]
[wpv-if arg_1="wpcf-birth" evaluate="getTodaysDate($arg_1) = 2"]
[wpv-post-title]
[wpv-post-featured-image]
[types field="birth" style="text" format="M j, Y"][/types]
[/wpv-if]
</wpv-loop>

And my evaluating function(added from settings for security):

function getTodaysDate($myDate) {
$today = date('md'); // 4 digit day month
$bday= date('md',$myDate); // 4 digit day month formatting try?? here is something wrong I guess.

if ( $bday== $today ) {
return 1;
} else {
return 2;
}
}

Thank you

#301263

This code returns no content at all. So it is not returning 1 or 2?

#301553

Types date fields are stored as timestamps, and DATE() returns also a timestamp

If you need to check against a custom date format, you need to adapt the custom function to get the custom field value, transforms it into a date value with just MMDD values, and then compare against today's date with that same MMDD value.

I am assuming you created the Fields with Types, as other wise it needs a much more customized function.
(transforming first into timestamp and then back to your custom date format)

I discussed this with my 2nd Tier Supporter and we might be of limited assistance only in this case, because it is not a default feature of Types Custom Fields / wpv-if evaluation.

In your function, you will need to compare the Today's date with the date passed from the wpcf-birth date.

Then you need to output either true or false, and use this to compare in wpv-if.
You would compare the Date (Today) with the Custom Fields date IN your function, and then output your Custom Field only if the functions output returns true, by evaluating as explained here:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/#using-custom-functions

Most important, in your function you need to get the values from somewhere, in your case from the Custom Fields wpcf-birth.

You need also to use PHP Date Functions to get the Today's date and transform to your customized Date Formats.
hidden link

I Apologize that I can't be of more detailed help here.

Thank you for understanding

#301627

I have already done that but it is not working thats why I gave my code above:

function getbday($bdate) {
$day = getdate();
$today = date('md', $day);
$bday = date('md', $bdate);
if ( $bday == $today ) {
return 1;
} else {
return 2;
}
}

Is there any error in this one?

Then I call it from inside with this:
<wpv-loop>
[wpv-if bdate="wpcf-birth" evaluate="getbday($bdate) = 1"]
[wpv-post-title]
[wpv-post-featured-image]
[types field="birth" style="text" format="M j, Y"][/types]
[/wpv-if]
</wpv-loop>

#301841

please try as follows:

function getbday($bdate) {

$day = date(m-d);
$today = date('md', strtotime($day));
$bday = date('md', strtotime($bdate));

if ( $bday == $today ) {
return 1;
} else {
return 2;
}
}
[wpv-if bdate="wpcf-birth" evaluate="getbday($bdate) = 1]Do something[/wpv-if]

Since this is a custom function, you would need to try to code it the way you need it.
It is not a Toolset Default use of our functions or default features, unfortunately I can be only of limited assistance when it comes to custom coding.

I thank you for understanding

#301956

Nope; this is what I have been trying for all time. But it is not working; so it needs some touch from your end rather than me trying to fix a puzzle with limitations that I dont even know.

It is not working in that form, sample can be found at :
hidden link

#301957

<wpv-loop>
[wpv-if bdate="wpcf-birth" evaluate="getbirthdate($bdate) = 1"]
[wpv-post-title]
[wpv-post-featured-image]
[types field="birth" style="text" format="M j, Y"][/types]
[/wpv-if]
</wpv-loop>

function getbirthdate($bdate) {

$day = date(m-d);
$today = date('md', strtotime($day));
$bday = date('md', strtotime($bdate));

if ( $bday == $today ) {
return 1;
} else {
return 2;
}
}

#301958

One thing I thought might be usefull is; not all my actors have bday data.
Some of them have it.

#303143

I apologize the to long delay on this.

I have created a short code for you, which you can try to use on your View.

We will also try to implement this in View as a "default" short code to use.
But this will need some more time to evaluate and QA processing.

Meanwhile you can proceed as this:

1. Create a Custom Post Type with "Types" = your actual profiles/talents/whatever
2. Associate a Custom Field to those Posts with "Types" = DATE (the actual "birthdate")
3. Create a View, list all your Custom Post Types previously created.
4. Insert this to functions.php:

function born_today_func( $atts ) {
    extract(shortcode_atts(array(
        'birthday' => get_post_meta(get_the_ID(), 'wpcf-your_slug', true),

    ), $atts)
           );

    if(((date('d', $birthday)) == date('d')) && (date('m', $birthday)) == date('m')){
        return 1;
    }else{
        return 0;
    }
}
add_shortcode( 'born-today', 'born_today_func' );

5. Evaluate like this in your view loop:
[wpv-if evaluate="[born-today] = '1'"]your_preferred_output_here[/wpv-if]

I tested this back to 1970's, different dates, months and combinations.

I did not create hundreds of profiles, as there simply is no time for it, but this seems to do the job as expected.

Please let me know if you agree.

Thank you

The topic ‘[Closed] How can I migrate my categorized content into different types of new posts(types’ is closed to new replies.