This topic has 6 replies, 3 voices, and was last updated 7 years by Radu.

  • Author
  • #157628
     wilfriedMarseille
    Participant

    Hello,

    I make shortcode to display mu custom post type in a list page like archive.php
    I put in a new page with my shortcode
    But I don’t which part of archive.php i have to take to get the same disign.
    This is my code but a put a simple ul li to list the post
    And i would like keep the archive.php design to list my post

    `<?php

    add_shortcode( ‘wildel’, ‘display_custom_post_type’ );

     

    function display_custom_post_type(){

    $args = array(

    ‘post_type’ => ‘telechargements’,

    ‘post_status’ => ‘publish’

    );

     

    $string = ”;

    $query = new WP_Query( $args );

    if( $query->have_posts() ){

    while( $query->have_posts() ){

    $query->the_post();

    $string .= ‘<li>’ . get_the_title() . ‘</li>’;

    }

    $string .= ‘</ul>’;

    }

    wp_reset_postdata();

    return $string;

    }

    ?>`

    If you love Ableton check my blog :
    www.zikrea.com

    #157630
     wilfriedMarseille
    Participant

    I make that cause i don’t find solution to put shortcode in a custom post type.
    So i remake in page to insert shortcode.

    But if you got a function to put shortcode in a custom post type is good too

    If you love Ableton check my blog :
    www.zikrea.com

    #157780
     Laura
    Moderator

    Hello, will assign the ticket to a higher support level who can help and advise you in your query.
    Thanks! ?

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

    #157923
     Radu
    Moderator

    Hi,

    Sorry but i don’t understand exactly what you want to acheive

    But from what i understand, you need to render a shortcode in that CPT

    You can do it by using a code like this

    if ( is_singular( ‘book’ ) ) {
    // conditional content/code
    echo do_shortcode([”]);
    }

    And that’s all

    cheers
    R.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #158082
     wilfriedMarseille
    Participant

    Yes you understand thanks.

    And if for example i want to put a revolution slider shortcode.
    Where can i found the conditional code ?

    If you love Ableton check my blog :
    www.zikrea.com

    #158147
     wilfriedMarseille
    Participant

    Hello

    The idea is not make a shortcode.

    Is use shortcode in Custom Post Type.
    For example if i want use [KLEO_SOCIAL_ICONS] in my custom post.

    But i don’t know how activate shortcode for custom post type.

    Thanks you

    If you love Ableton check my blog :
    www.zikrea.com

    #158341
     Radu
    Moderator

    Any shortcode can be run from PHP like this

    COPY CODE
    
    <?php echo do_shortcode("[shortcode]"); ?>
    

    Cheers
    R

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
Viewing 7 posts - 1 through 7 (of 7 total)

The forum ‘Bugs & Issues’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?