• I’m trying to mod an existing WP plug-in, the goal to pull the specific posts date, and insert it into the a href tags/links that were posted in that blog entry. The “link” is already there, and my interjecting this custom attribute is already taken care of and works. What doesn’t work is the date part. I’m just trying to copy the date of that specific post into the HTML link that is on the blog entry.

    In other words what used to be <a href="whateversite.com">click</a> on original blog post, now becomes <a href="whateversite.com" alt="$date">click</a> in each blog entry (this will mod all visible blog entries to do the same)

    where $date is from that specific day’s entry. The mod does insert the alt attribute into the a href tags, what it won’t do is insert that post’s date. I’ve tried using alt="post->$post_date" but that didn’t work. $post_date by itself just repeats $post_date. I suppose I could be missing a require/link in WP, but you’d think a WP Plug-in would have that already taken care of (though I’ll admit this plug-in’s function wasn’t really intended for this use).

    Any ideas what I’m missing?

Viewing 4 replies - 1 through 4 (of 4 total)
  • 1. Does the plugin already scope $post to global? Look for a line like this:

    global $post;

    Then you should be able to use $post->post_date (note the date will be in MySQL’s DATETIME format: YYYY-MM-DD hh:mm:ss).

    2. What does the line creating the <a> element look like in the plugin? This is important for how you pass the variable to it. Knowing what plugin we’re discussing here might help, as well.

    3. Why do you want this as a link’s alt attribute?

    Thread Starter dementis

    (@dementis)

    1. no – I put it in manually, and that “removed” all the “links” on render.

    2 and 3:
    I’ll “come clean” on this. I made this thread being general as possible, since it tends to get more attention on here, than specifics (which is what I’m trying to accomplish).

    I modified IIG (Iimage Gallery) to inject rel="lightbox[$post->post_date]"
    into line 64:
    $ig_settings['ig_before_each'] = '<a href="%src" rel="lightbox[$post->post_date]" class="gallery_item">';
    So I can use lightbox-js as the gallery front-end on blog entries, but use IIG’s convenient thumb-generation and linking (with standalone disabled).

    In lightbox, when things are in [thesetypeofbrackets] they are classified as “group-id’s”, making any image with the same group-id, linked together. My “hacked-up” IIG “works” but the problem was every single blog entry with pictures would share the same group-id. I wanted the images/slides to be only linked on a per-post/day basis – hence why I figured a $date variable would be able to distinguish all past and future entries, and not share them all in the same group-id – only images on the same day/post would share the same group-id.

    As for my little modification to IIG and its “working condition”, it “works”, but it tends to make wp-admin up-chuck itself with header errors. I can still work inside of the admin and write posts, provided I’m not logged out. Once I try to log back in, the errors prevent me from proceeding – my workaround relies on me renaming the IIG filter, log in, rename it back, and write whatever post (yes, I know this is criminally inefficient but so far it has been the quickest way to generate thumbs/links to the full size image, and be able to inject the much needed lightbox statement).

    Thread Starter dementis

    (@dementis)

    *bump*

    Hi,
    I found your thread by searching for a solution for the same problem. Thinking of that, I got the expected results in a simple, stupid, but functional way, since i know shit about PHP. I just passed ‘%alt’ as an attribute to “lightbox” –> rel=”lightbox[%alt]”.

    Then, in my posts, i only have to assign the same alt attribute to all images on the same gallery. Okay, i lose any other uses for the “alt attribute”, but i get what i want.

    Take a look at my last and third-last posts on my blog: narua.org/blog. It’s in Portuguese, but well, we’re talking about pictures, aren’t we?

    Hope it helps you as well.
    Paulo.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Get Date from posts or mySQL for Plug-in mod.’ is closed to new replies.