Get pages by title instead of path to prevent duplicate

This commit is contained in:
Brian Miyaji
2014-03-16 14:18:38 +11:00
parent 12864c49a5
commit f2c55dd79e
3 changed files with 10 additions and 5 deletions

View File

@@ -192,7 +192,7 @@ if ( class_exists( 'WP_Importer' ) ) {
list( $team_name, $result, $outcome ) = $team;
// Find out if team exists
$team_object = get_page_by_path( $team_name, OBJECT, 'sp_team' );
$team_object = get_page_by_title( $team_name, OBJECT, 'sp_team' );
// Get or insert team
if ( $team_object ):
@@ -252,11 +252,16 @@ if ( class_exists( 'WP_Importer' ) ) {
// Add outcome slugs to team outcomes array
foreach ( $outcomes as $outcome ):
// Continue if outcome doesn't exist
if ( $outcome == null ):
continue;
endif;
// Remove whitespace
$outcome = trim( $outcome );
// Get or insert outcome
$outcome_object = get_page_by_path( $outcome, OBJECT, 'sp_outcome' );
$outcome_object = get_page_by_title( $outcome, OBJECT, 'sp_outcome' );
if ( $outcome_object ):
@@ -331,7 +336,7 @@ if ( class_exists( 'WP_Importer' ) ) {
unset( $player[0] );
// Find out if player exists
$player_object = get_page_by_path( $player_name, OBJECT, 'sp_player' );
$player_object = get_page_by_title( $player_name, OBJECT, 'sp_player' );
// Get or insert player
if ( $player_object ):

View File

@@ -155,7 +155,7 @@ if ( class_exists( 'WP_Importer' ) ) {
$i = 0;
foreach ( $teams as $team ):
// Get or insert team
$team_object = get_page_by_path( $team, OBJECT, 'sp_team' );
$team_object = get_page_by_title( $team, OBJECT, 'sp_team' );
if ( $team_object ):
if ( $team_object->post_status != 'publish' ):
wp_update_post( array( 'ID' => $team_object->ID, 'post_status' => 'publish' ) );

View File

@@ -118,7 +118,7 @@ if ( class_exists( 'WP_Importer' ) ) {
list( $name, $leagues, $seasons ) = $row;
$team_object = get_page_by_path( $name, OBJECT, 'sp_team' );
$team_object = get_page_by_title( $name, OBJECT, 'sp_team' );
if ( ! $name || $team_object ):
$this->skipped++;