-
AuthorPosts
-
June 2, 2017 at 5:34 pm #803130
Hello,
I found a thread created by Ismael some time ago with information on how to create a custom content element block to display post meta info on the ALB when using it to create posts.
I was wondering if someone could help me rework this code so that it ONLY shows the post date, nothing more.
The link to the thread is here: https://kriesi.at/support/topic/post-meta-information-not-appearing-on-single-post-in-restaurant-theme-in-enfold/
The code here:
<?php /** * Comments Element * Adds a comment form to the page */ // Don't load directly if ( !defined('ABSPATH') ) { die('-1'); } if ( !class_exists( 'avia_post_meta_info' ) ) { class avia_post_meta_info extends aviaShortcodeTemplate{ /** * Create the config array for the shortcode button */ function shortcode_insert_button() { $this->config['name'] = __('Post Meta', 'avia_framework' ); $this->config['tab'] = __('Content Elements', 'avia_framework' ); $this->config['icon'] = AviaBuilder::$path['imagesURL']."sc-comments.png"; $this->config['order'] = 28; $this->config['target'] = 'avia-target-insert'; $this->config['shortcode'] = 'av_post_meta'; $this->config['tinyMCE'] = array('disable' => "true"); $this->config['tooltip'] = __('Add the post meta infos', 'avia_framework' ); //$this->config['drag-level'] = 1; } /** * Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas * Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container * Less often used: $params['data'] to add data attributes, $params['class'] to modify the className * * * @param array $params this array holds the default values for $content and $args. * @return $params the return array usually holds an innerHtml key that holds item specific markup. */ function editor_element($params) { $params['innerHtml'] = "<img src='".$this->config['icon']."' title='".$this->config['name']."' />"; $params['innerHtml'].= "<div class='avia-element-label'>".$this->config['name']."</div>"; $params['content'] = NULL; //remove to allow content elements return $params; } /** * Frontend Shortcode Handler * * @param array $atts array of attributes * @param string $content text within enclosing form of shortcode element * @param string $shortcodename the shortcode found, when == callback name * @return string $output returns the modified html string */ function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "") { $the_id = get_the_ID(); $output = '<header class="entry-content-header">'; $output .= "<span class='post-meta-infos'>"; $markup = avia_markup_helper(array('context' => 'entry_time','echo'=>false)); $output .= '<time class="date-container minor-meta updated" {$markup}>'.get_the_time(get_option('date_format'))."</time>"; $output .= "<span class='text-sep text-sep-date'>/</span>"; if ( get_comments_number() != "0" || comments_open() ){ $output .= "<span class='comment-container minor-meta'>"; ob_start(); comments_popup_link( "0 ".__('Comments','avia_framework'), "1 ".__('Comment' ,'avia_framework'), "% ".__('Comments','avia_framework'),'comments-link', "".__('Comments Disabled','avia_framework')); $comment = ob_get_clean(); $output .= $comment; $output .= "</span>"; $output .= "<span class='text-sep text-sep-comment'>/</span>"; } $taxonomies = get_object_taxonomies(get_post_type($the_id)); $cats = ''; $excluded_taxonomies = apply_filters('avf_exclude_taxonomies', array('post_tag','post_format'), get_post_type($the_id), $the_id); if(!empty($taxonomies)) { foreach($taxonomies as $taxonomy) { if(!in_array($taxonomy, $excluded_taxonomies)) { $cats .= get_the_term_list($the_id, $taxonomy, '', ', ','').' '; } } } if(!empty($cats)) { $output .= '<span class="blog-categories minor-meta">'.__('in','avia_framework')." "; $output .= $cats; $output .= '</span><span class="text-sep text-sep-cat">/</span>'; } $output .= '<span class="blog-author minor-meta">'.__('by','avia_framework')." "; $markup = avia_markup_helper(array('context' => 'author_name', 'echo'=>false)); $output .= '<span class="entry-author-link" $markup>'; $output .= '<span class="vcard author"><span class="fn">'; ob_start(); the_author_posts_link(); $author = ob_get_clean(); $output .= $author; $output .= '</span></span>'; $output .= '</span>'; $output .= '</span>'; $output .= '</span>'; $output .= '</header>'; return $output; } } }
Thanks in advance, would be lovely if Ismael could get me code to show only post date.
June 4, 2017 at 2:52 pm #803601Hey hizzacked,
Here is an article on how to add shortcode to show date
No need for all the complexity from above.
If you need further assistance please let us know.
Best regards,
VictoriaJune 4, 2017 at 4:21 pm #803625Thank you Victoria! It works.
However I do have one question. Is this date going to change as the day changes? What we’re looking for is the date to show up on a post that is created with the advanced editor so that it shows the date the post was made, I’m concerned that this [date] shortcode is going to display the day of the month on the current day you’re looking at the post.
June 4, 2017 at 5:54 pm #803652Hi hizzacked,
Here are some threads with solutions that might work for you.
https://kriesi.at/support/topic/code-to-insert-in-order-to-show-blog-meta-elements-in-blog-posts-using-avia/#post-489041
Best regards,
VictoriaJune 4, 2017 at 7:10 pm #803673Thank so much Victoria! The code snippets seem to be working great :)
June 5, 2017 at 4:30 am #803745Hi,
Great, glad you got it working and thanks for the feedback. Please let us know if you should need any further help on the topic or if we can close it.
Best regards,
RikardJune 5, 2017 at 4:51 am #803752Awesome, thanks so much, it seems to be doing everything I need it to do. Feel free to close topic!
June 5, 2017 at 11:17 am #803815 -
AuthorPosts
- The topic ‘Paging Ismael – Post Meta Infos in ALB’ is closed to new replies.