• I’ve been working on this for a while now and have hit the proverbial wall. I worked with it myself for a week or so before going to Grok and ChatGPT to try and help. I get conflicting answers.
    The following is what I fed into AI –
    “I am developing a website using WordPress and the ‘Events Manager’ plug in. I want to produce lists from the events entered. I’ve set up two special attribute fields. One is labeled ‘SMGRAPHIC’ and the other is ‘SMLINK’. I want the ‘SMGRAPHIC’ attribute to load a graphic stored on my website. When that graphic is pressed, I want it to access a website stored in ‘SMLINK’ and open that website in a new window.”

    On all AI tried I received basically the following to be placed in the SMGRAPHIC field:


    <a href="#_ATT{SMLINK}" target="_blank" rel="noopener noreferrer">
    <img src="https://your-site/example....." alt="Visit link"</a>

    During multiple times testing entering this request (with minor variations), I was told it should work. When tested, the graphic displays, but the link is always a re-route into the working website in a new window. It does NOT load the site stored in SMLINK.
    I then saw another analysis that said nesting an attribute within an attribute would NOT work unless some php adjustments were made or something about working it through shortcode.

    It was at that point I decided to come to the experts. Am I spinning my wheels here?

    Thanks!

    ed

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • My understanding is that you’re trying to have an image for each event in the event list and when you click on it you want it go to to some external website specified by #_ATT{SMLINK}. Do I have that right?

    Normally the event list shows the featured image for each event. You can specify the featured image when creating the event so you really don’t need the #_ATT{SMGRAPHIC} since you can just use the featured image.

    In the Event List the #_EVENTIMAGE placeholder is used to display the featured image. You can override the #_EVENTIMAGE placeholder to turn it into a link that will go to the #_ATT{SMLINK} location when you click on the image. To do that use the following code snippet:

    add_filter('em_event_output_placeholder','my_em_styles_placeholders',1,3);
    function my_em_styles_placeholders($replace, $EM_Event, $result){
    if( preg_match( '/#_EVENTIMAGE.*/', $result ) ) {
    $url = get_post_meta($EM_Event->post_id, 'SMLINK', true);
    if ( empty( $url ) ) {
    $url = esc_url($EM_Event->get_permalink());
    $replace = '<a href="' . $url . '">' . $replace . '</a>';
    }
    else {
    $replace = '<a href="' . $url . '" target="_blank">' . $replace . '</a>';
    }
    }
    else if( preg_match( '/#_EVENTLINK.*/', $result ) ) {
    $url = get_post_meta($EM_Event->post_id, 'SMLINK', true);
    if ( !empty( $url ) ) {
    $replace = preg_replace('/(<a href=")[^"]*">([^<]*)<\/a>/', '${1}' . $url . '">' . '$2' . '</a>', $replace);
    }
    }
    else if( preg_match( '/#_EVENTURL.*/', $result ) ) {
    $url = get_post_meta($EM_Event->post_id, 'SMLINK', true);
    if ( !empty( $url ) ) {
    $replace = $url;
    }
    }
    return $replace;
    }

    You can use the Code Snippets plugin to add this code snippet.

    Let me know if I misunderstand your request.

    • This reply was modified 8 months, 1 week ago by joneiseman.
    Thread Starter BigBlueMan

    (@bigblueman)

    It may take some time for what you wrote to sink it as I fool with it. Thank you for the effort.

    To clarify a bit, I use the same image for every record in the list. It’s like a ‘CLICK HERE’ graphic, not something unique. So I use the SMGRAPHIC to place that image (using img src). The ‘wild card’ here is the SMLINK. There will be dozens of records, each going to a different URL.

    My thought was to be able to use SMGRAPHIC to place picture, then be able to simply change the link on a record by changing it in SMLINK.
    I know I could do this ‘manually’, by skipping the SMLINK field and putting the URL directly in the command at SMGRAPHIC, but I was trying to come up with something that would make adding (or changing the link) easier by not having to do that for every record.
    Ideally? Just drop the URL in SMLINK and whatever is currently in there is where the click takes you.

    Again, let me go through what you wrote. I appreciate it! It’s a learning process here. You may be right and I can just establish a default ‘feature image’ and make it work that way.

    ed

    I should point out that I’ll rarely (if ever) use an individual event page. This is strictly a way of lining up 5-600 hundred already established events on the web and getting visitors to them.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Linking from within a custom attribute’ is closed to new replies.