May 4, 2011

Custom PHP find and replace on post_content | CyberSEO Pro | Support Forum

Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_TopicIcon
Custom PHP find and replace on post_content
Topic Rating: 0 Topic Rating: 0 Topic Rating: 0 Topic Rating: 0 Topic Rating: 0 Topic Rating: 0 (0 votes) 
June 21, 2023
12:43 pm
Avatar
rich.frost.uk
Member
Members
Forum Posts: 3
Member Since:
October 18, 2022
sp_UserOfflineSmall Offline

I've created a CSV dump which pulls in the title and the tag, on the advanced tab I have set my template in the post content section.

In the custom PHP section I want to do a find and replace on the content looking for say XXX and replace it with the tag that I imported.

So something like this:

Login to see the code

Does anyone know the correct way to pull the stored tag as $post['post_tags'] doesn't work ?

June 21, 2023
12:51 pm
Avatar
CyberSEO
Admin
Forum Posts: 3909
Member Since:
July 2, 2009
sp_UserOfflineSmall Offline

There is no $post['post_tags'] variable defined in CyberSEO Pro. There is a tag array variable and it is called $post['tags_input']. Please read the manual: Login to see this link

Also note that $post['tags_input'] is empty and can be used to add additional tags via your PHP snippet. The Login to see this link only have categories, not tags. So if you want to generate WordPress-specific post tags from the RSS categories, you have to use the $post['categories'] array instead.

June 21, 2023
1:12 pm
Avatar
rich.frost.uk
Member
Members
Forum Posts: 3
Member Since:
October 18, 2022
sp_UserOfflineSmall Offline

Ok that’s what I thought but what actually need to replace is the variable that I stored in the CSV dump under Tags. In this instance it would be the second input :

Some title|mytag

Title|Tags

The reason being is that in my post content template I have a shortcode that I want to include the tag within.

Login to see the code

So I want to replace the XXX with the tag being pulled from the CSV dump.

June 21, 2023
2:04 pm
Avatar
CyberSEO
Admin
Forum Posts: 3909
Member Since:
July 2, 2009
sp_UserOfflineSmall Offline

Tags are stored as an array, not a string. So I would suggest that you use them as

Title|Custom

So your post template should look like this:

Login to see the code

Note that CyberSEO Pro exports everything as XML, including CSV files and raw text dumps. Please read this article: Login to see this link

June 21, 2023
3:50 pm
Avatar
rich.frost.uk
Member
Members
Forum Posts: 3
Member Since:
October 18, 2022
sp_UserOfflineSmall Offline

Thanks for that, it works great!

June 30, 2023
11:02 am
Avatar
CyberSEO
Admin
Forum Posts: 3909
Member Since:
July 2, 2009
sp_UserOfflineSmall Offline

Login to see this link

Forum Timezone: Europe/Amsterdam

Most Users Ever Online: 541

Currently Online:
14 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

ninja321: 84

s.baryshev.aoasp: 68

Freedom: 61

Pandermos: 54

MediFormatica: 49

B8europe: 48

Member Stats:

Guest Posters: 337

Members: 2816

Moderators: 0

Admins: 1

Forum Stats:

Groups: 1

Forums: 5

Topics: 1625

Posts: 8271

Newest Members:

jeremyboucher, lthompson2709, MAC, duty3canada, backlinkmorocco, dmitrypehovskiwork

Administrators: CyberSEO: 3909