motion2082 on "[Plugin: Import any XML or CSV File to WordPress] IF ELSE for Agents"

ساخت وبلاگ

motion2082
Member
Posted 1 week ago #

Hey guys,

Trying to make a php function for my Agents Tab. Basically need it to do the following

[IF({agent[contains(.,'john-doe')]})]
//make agents
contains "John Doe Manager"
[ELSEIF({agent[contains(.,'penny-doe')]})]
//make agents
contains "Penny Doe Assistance manager"
[ENDIF]

Is this the right way to go about it?

https://wordpress.org/plugins/wp-all-import/

Something like that could work, but you might find it a bit easier to use a full PHP function, as described here: http://www.wpallimport.com/documentation/developers/execute-php/

motion2082
Member
Posted 1 week ago #

Not the best with PHP, any examples of scripts/functions other users are using?

For you, it would be something like this (can be pasted in to the Function Editor):

function export_agent_lookup( $agent ) { $replacements = array( "john-doe" => "John Doe Manager", "penny-doe" => "Penny Doe Assistance manager" ); retu str_replace( array_keys($replacements), $replacements, $agent);
}

You can read more about using PHP functions here: http://www.wpallimport.com/documentation/developers/execute-php/

Nice one guys :)

Is it possible to have an option for both agents too?

So both John & Penny Doe together?

I'm sort of thinking going by your code above

function export_agent_lookup( $agent ) { $replacements = array( "john-doe" => "John Doe Manager", "penny-doe" => "Penny Doe Assistance manager" "john-doe,penny-doe" => "John Doe Manager,Penny Doe Assistance manager" ); retu str_replace( array_keys($replacements), $replacements, $agent);
}

Trialing this atm

[export_agent_lookup({listingAgent[1]})] in field

function

function export_agent_lookup( $agent ) { $replacements = array( "1" => "John Doe – DirectorLicenseeSales Agent", "2" => "Penny Doe – Sales Agent", "1" . "2" => "John Doe – DirectorLicenseeSales Agent" . ">" . "Penny Doe – Sales Agent" ); retu str_replace( array_keys($replacements), $replacements, $agent);
}

not sure if it will work, your thoughts?

I'm not sure, but you can run as many tests as you like here: http://www.wpallimport.com/debug/

motion2082
Member
Posted 7 minutes ago #

Don't know if this helps, I select agents in WordPress like this http://imgur.com/wfNIYI9

Which uses the MetaBox plugin

You can see a block of code that generates a list of agent posts titles to use in Metabox Options around line #52 in the “config-meta-boxes.php” file located under framework/meta-box/ directory.

Look at this screenshot: http://jmp.sh/iAe8gpc

Now you can find the MetaBox field code around line #320 in the same file.

Helping screenshot: http://jmp.sh/9OHQWEb

So essentially I just have to make my function select two ID's in the agent_post->id in the agents_array

motion2082
Member
Posted 5 minutes ago #

I wonder if I can just reuse this code for my import https://jumpshare.com/v/q49tAdr5kEsH9u9NEakz

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 232 تاريخ : دوشنبه 6 ارديبهشت 1395 ساعت: 13:32