Join the Soledad Facebook Users Group here
for Share, assistance, discussion, and Updates related to Soledad WordPress Theme.

If you can't create a new ticket - you can send us an email via our contact form and we will get back to you.

Okay
  Public Ticket #3435751
Custom shortcode
Closed

Comments

  • Nurmukhan started the conversation

    I created my own shortcode to display popular news for the day, week, month and year, data from the Post view Counter plugin. When outputting the shortcode, nothing is output, and all the collected on the main page disappear and in its place becomes an empty output of news. In my shortcode, I added my own css and js, adding them to function.php and activating them in the template settings as a shortcode. Here is an example of my php code: 

    <div id="tab1" class="tab active"><?php
    $today_start = date('Y-m-d 00:00:00');
    $today_end = date('Y-m-d 23:59:59');

    $popular_posts = pvc_get_most_viewed_posts(array(
        'posts_per_page' => 4,
        'orderby' => 'views',
        'order' => 'DESC',
      'start' => $today_start,
      'end' => $today_end,
        'date_query' => array(
            'after' => $today_start,
            'before' => $today_end,
            'inclusive' => true,
        ),
    ));

    foreach ($popular_posts as $post) {
        setup_postdata($post);
    ?>
        <div class="gallery-item">
            <?php if (has_post_thumbnail()) { ?>
                <div style="background-image: url(<?php esc_url(the_post_thumbnail_url('full')); ?>);">
                    <?php the_post_thumbnail('gallery-item', array('class' => 'custom-thumbnail-class')); ?>
                </div>
            <?php } ?>
            <span class="caption">
                <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                <?php echo get_the_date('F j, Y'); ?>
            </span>
        </div>
    <?php
    }
    wp_reset_postdata();
    ?>
        </div> 

  •  2,610
    PenciDesign replied

    Hi,

    For this case, please send me your WordPress admin account in a PRIVATE reply.
    I'll log in and try to help you check it.

    Regards,
    PenciDesign.



  •   Nurmukhan replied privately
  •  2,610
    PenciDesign replied

    Hi,

    Please send me the screenshot of the settings page you've added this code.

    Regards,
    PenciDesign.


  • Nurmukhan replied

    Если я добавлю шорткод без WP Bakery и через сделать шорткод на странице, но результат будет таким же

    Attached files:  Functions.png
      Shortcode.png
      Home.png
      Shortic.png

  •  2,610
    PenciDesign replied

    Hi,

    Please read the document at this link to understand how to register the shortcode correctly: https://www.wpbeginner.com/wp-tutorials/how-to-add-a-shortcode-in-wordpress/

    Regards,
    PenciDesign.


  •   Nurmukhan replied privately
  •  2,610
    PenciDesign replied

    Hi,

    Have you added this code to your site?

    add_shortcode('my_shortcode','my_custom_shortcode');
    

    Regards,
    PenciDesign.


  •   Nurmukhan replied privately
  •  2,610
    PenciDesign replied

    Hi,

    That really hard to check this issue without logging in to your dashboard.

    You should turn on the WP_DEBUG to check the debug log: https://wordpress.org/documentation/article/debugging-in-wordpress/

    Regards,
    PenciDesign.