Forum Replies Created

Viewing 15 replies - 31 through 45 (of 115 total)
  • Thread Starter moxymore

    (@moxymore)

    Thank you for your answer. Greetly appreciated.

    Thread Starter moxymore

    (@moxymore)

    Thank you for your reply. This was the good way to proceed you have right.

    But by thinking a bit more, creating a function like this wasn’t necessary since I expected to make only one database call for all the taxonomies and terms. A function like this will make calls to the DB each time it is fired.

    I have instead created a custom php file, and I have require_once() it in my function.php, and include() it on specific single-xxx.php page. By doing this, I can grab the taxonomies_object in one DB call, and simply use the variables directly. This has another advantage : there is no need to make variable as $GLOBALS.

    Thank you anyway for your spent time, greatly appreciated.

    Same issue for me too.

    I have switched the plugin from Custom Post Type Permalink to https://www.ads-software.com/plugins/wp-better-permalinks/

    No problem with this one to display parent->child hierarchy. And the plus is it’s UI, you don’t have to type anything, just click and choose.

    • This reply was modified 5 years, 10 months ago by moxymore.
    Thread Starter moxymore

    (@moxymore)

    Hi there,

    Little up for this, since you have just released an update without resolving this CSS issue.

    Thank you.

    Thread Starter moxymore

    (@moxymore)

    Don’t worry, I saw it was fixed in the 1.6.1. Thanks.

    Thread Starter moxymore

    (@moxymore)

    Thank you again bcworkz for your answer,

    I took some times to figured out what was the issue, but I can’t find it. The complex structure of my website with a lot of custom taxonomies which impacts directly the url structure makes it really hard to set it up correctly.

    I have opted for another solution, just correct me if I have wrong : I have configured my SEO plugin to automatically redirect all attachment post to its parent. I have, per security, put a no-index for all attachment.

    I think it’s the best solution for me, because my website will never use these links. The only benefit they give me for the frontend are for captions and descriptions which can be shown in my lightbox.

    Regards.

    Thread Starter moxymore

    (@moxymore)

    Well, this is not as simple. In facts, what I have written doesn’t solve the issue… because the database reference isn’t updated.

    I don’t know if you are able to solve this, but if not, you have to inform the user on How to redirect attachments pages to the original post, because if not, google referenced image will lead to a 404 page.

    Thread Starter moxymore

    (@moxymore)

    Hi there, sorry I was busy.

    I have probably found the issue. If you take a look closely at what your plugin does, it simply rename the file on upload without changing its metadata. And because of that, the post created for the attachment (every single image has an internal wordpress post) has an url which references the name BEFORE the rename.

    In short, you probably have to use wp_update_attachment_metadata() just after having renamed the image in order to update the image’s metadata (here, the post’s name).

    Take a look at this example :

    [215] => WP_Post Object
            (
                [ID] => 215
                [post_author] => 1
                [post_date] => 2016-12-10 20:46:16
                [post_date_gmt] => 2016-12-10 19:46:16
                [post_content] => 
                [post_title] => Alternative - League of Legends - 03
                [post_excerpt] => 
                [post_status] => inherit
                [comment_status] => open
                [ping_status] => closed
                [post_password] => 
                [post_name] => league-of-legends-faire-un-penta-avec-le-mur-d-anivia-c-est-possible_20890_wide1
                [to_ping] => 
                [pinged] => 
                [post_modified] => 2016-12-10 20:48:51
                [post_modified_gmt] => 2016-12-10 19:48:51
                [post_content_filtered] => 
                [post_parent] => 126
                [guid] => https://voluntary_hidden_path.jpg
                [menu_order] => 0
                [post_type] => attachment
                [post_mime_type] => image/jpeg
                [comment_count] => 0
                [filter] => raw
            )

    Here is a part of the array extracted with get_attached_media( ‘image’ ). For this image, you can see all its related metadata. You can clearly see that [post_name] hasn’t been modified during upload and corresponds to the original filename BEFORE upload.

    And because the standard permalink structure for images posts take this [post_name] for the url, this leads to a 404 error if you click on the link related to the post image.

    The only thing you have to do is to update this [post_name] just AFTER the rename process in order to give it the same value as your sanitize_file_name (without omitting to add a $count=++ in order to avoid duplicates and potential error).

    Do you get it?

    • This reply was modified 7 years, 11 months ago by moxymore.
    Thread Starter moxymore

    (@moxymore)

    Allright, I had a typo error in “foreach($media as $media)” where I have forgotten the plural => “foreach($medias as $media)”

    I have finally understood this foreach ?? Thank you.

    Thread Starter moxymore

    (@moxymore)

    Thank you for the clarification. But I need a proper example on how to treat this array, because I probably have to use foreach in order to achieve what I want. The thing is… I always failed to use foreach()…

    With get_attached_media( ‘image’ ); I have the following array :

    Array
    (
        [214] => WP_Post Object
            (
                [ID] => 214
                ...
            )
    
        [213] => WP_Post Object
            (
                [ID] => 213
                ...
            )
        [216] => WP_Post Object
            (
                [ID] => 216
                ...
            )
    
        [215] => WP_Post Object
            (
                [ID] => 216
                ...
            )
    )

    Now, how can I write my function in order to tell it : “for each post object => do a wp_set_object_terms( $post_id, array($cma_slug_sanitized), ‘cma_category’ );”?

    This sounds kinda a newbie question, but when some principle are immediately understood, other aren’t, and this is the case for “foreach” (php.net didn’t helped me for it).

    Thank you in advance.

    [EDIT]

    I have tried with the 2 following codes :

    $medias = get_attached_media( 'image' );
    			foreach($media as $media):
    			  wp_set_object_terms( $media, array($cma_slug_sanitized), 'cma_category' );
    			endforeach;
    $medias = get_attached_media( 'image' );
    			foreach($media as $media):
    			  wp_set_object_terms( $media->ID, array($cma_slug_sanitized), 'cma_category' );
    			endforeach;
    • This reply was modified 7 years, 11 months ago by moxymore.
    Thread Starter moxymore

    (@moxymore)

    Forget it, I have solved the issue. It cames for an import of post which have saved some old informations which needed to be deleted. And moreover which were not related to your plugin.

    Apologies.

    Thread Starter moxymore

    (@moxymore)

    Hi,

    Your plugin is finally working, I have solved the issue 3 weeks ago. The thing is I had to put ID on each selectors. Putting a mix of div/class were buggy.

    That’s why my recommendations to make it works properly on the first attempt is to put/set a unique ID for every single element.

    PS : I have resetted my website with a fresh new install, you were unable to see it working.

    Just keep in mind one concept if you think user friendliness matters for your plugin : STEPS are the key. What I mean is instead of showing all the available information at a time, just separate it into steps, in order to finally display ONLY what the user needs to be displayed.

    The benefits of it are multiple :

    – The creation of a list become easy as fuck if he has to follow a step by step query construction. This means a better productivity for creating lists.
    – No useless informations are displayed, only what the user have checked for this query
    – Better visibility to modify the query if something is wrong, or if he has forgotten to check something.

    Now, if you expect to include additional UI, I wanna say “why not”. But imo, first things first! This means, in short :

    STEP 1 : Modify your actual UI with the best idea you have.
    STEP 2 : Release the version and ask what people are thinking about it.
    STEP 3 : With all these opinions, you’ll have enough data to optimize your new UI, and will be able to start for additional UI if really you want to.

    But first, just my 2 cents, work at one project at a time.

    @cwfaraday : Let’s discuss it on my skype : mooks6767 or directly via email : [email protected]

    • This reply was modified 7 years, 11 months ago by moxymore.

    Not a problem ??

Viewing 15 replies - 31 through 45 (of 115 total)