I am running a wordpress site which has products. In DB, i have a table which contains about 12 columns but the major ones which i think are relevant are: 1-> post parent(ID) 2->post_type
post parent is the the ID of the post parent. IF a product contains images,post parent ID points to the product. most especially images(attachment)have post parent. Not all posts have post parent.
post type tells you the file type eg image.
the problem now is that i have some products which contains more than 7 images and i want to remove 2 and leave just 5 for each product. to get the picture more clearer, i created a small snippet, this is of course incorrect. I just hope it'll shed more light on the issue:
#SELECT * FROM TABLE where post_type = 'attachment'
#IF SUM(distinct post_parent) > 7,
#THEN post_parent - 2;#
what i am trying to do is count the post parent ID and if its more that 7, i want to remove 2. hope you get the point and thanks for your help.
Aucun commentaire:
Enregistrer un commentaire