Shortcodes disappearing from pages/templates

Posted in: Newspaper
Post count: 15

I have a custom shortcode from another plugin that I want executing on my page. If I edit the page without tagdiv composer, add it in the proper spot, and save. It works fine. But if I ever update anything with tagdiv composer it gets removed. Is there a way to stop this from happening? I couldn’t find a way inside tagdig composer to add external shortcodes and have them execute properly.

Post count: 27744

Hi,

A shortcode can be inserted by using the element called “Column text” or “Text with title”. “Column text” and “text with title” elements have a button called “edit content” and if you click on that button, the WP Editor will open, and you can add some text/code/shortcode there. Close the WP Editor from X, save the changes from Composer and view the page to see the changes.

Thank you!

Post count: 15

I used both Column Text and Text with Title options. This works nicely and saves once. However, every time I reload the TD Composer I get an error:
Errors at columns elements: 19(models) : 20(dom). The model does not match the content Current state has involved an issue. You could try an UNDO operation (CTRL+Z / CTRL+SHIFT+Z)

The shortcode I put in behaves like a normal shortcode and simply returns some html output.

If I remove the shortcode, everything goes back to working fine. For some reason having it execute a shortcode is causing this error.

Post count: 27744

Hi,

Please let me know what your shortcode looks like.

Thank you!

Post count: 15

function display_guest_author_shortcode() {
// Get the current post's ID
global $tdb_state_single;
$post_id = $tdb_state_single->post_id->__invoke();

// Check if the custom field 'guest_author' exists
$guest_author = get_post_meta($post_id, 'guest_author_name', true);

// Display the custom field value if it exists, otherwise show 'Staff'
$author_name = esc_html(!empty($guest_author) ? $guest_author : 'Staff');

$html = '<div class="td_block_wrap tdb_single_author td-pb-border-top td_block_template_1 tdb-post-meta" style="display:inline-block;font-family:Rubik!important;font-size: 13px!important;line-height: 1!important;font-weight: 400!important;text-transform: capitalize!important;padding-right:10px !important;margin-bottom:16px;color:#444;font-family:\'Open Sans\',\'Open Sans Regular\',sans-serif;font-size:11px;font-weight:400;clear:none;vertical-align:middle;line-height:1">

<div class="tdb-block-inner td-fix-index" style="display:flex;align-items:center"><div class="tdb-author-name-wrap" style="display:flex;align-items:baseline"><span class="tdb-author-by" style="margin-right:3px;font-family:Rubik!important;font-size:13px!important;line-height:1!important;font-weight:400!important;text-transform:capitalize!important">By</span> ' . $author_name . '</div></div></div>';

return $html;
}

// Register the shortcode
add_shortcode('display_guest_author_byline', 'display_guest_author_shortcode');

Then we do simple [display_guest_author_byline]

Goal was to replace the Author byline widget with something that will read a custom field (Guest Author) because none of the existing plugins seem to play nice with Newspaper theme. Simply publishing a custom field also didn’t work because we wanted some logic about showing ‘Staff’ when no Guest Author was there.

Post count: 27744

Hello,

Unfortunately, these modifications exceed my knowledge. There needs to be a correction in the code because there is something that interferes.
You can check these topics
https://forum.tagdiv.com/topic/display-guest-author-with-custom-fields/ -> https://forum.tagdiv.com/topic/utilizing-author-templates/

Thank you!

Viewing 6 posts - 1 through 6 (of 6 total)
The forum ‘Newspaper’ is closed to new topics and replies.