-
Author
-
April 5, 2017 at 00:44 #157628wilfriedMarseilleParticipant
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.comApril 5, 2017 at 00:48 #157630wilfriedMarseilleParticipantI 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.comApril 6, 2017 at 14:01 #157780LauraModeratorHello, 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 solutionLaura 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 🙂
April 7, 2017 at 18:29 #157923RaduModeratorHi,
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 solutionApril 10, 2017 at 16:01 #158082wilfriedMarseilleParticipantYes 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.comApril 11, 2017 at 02:32 #158147wilfriedMarseilleParticipantHello
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.comApril 12, 2017 at 20:30 #158341RaduModeratorAny shortcode can be run from PHP like this
COPY CODE<?php echo do_shortcode("[shortcode]"); ?>
Cheers
RHi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution -
AuthorPosts
The forum ‘Bugs & Issues’ is closed to new topics and replies.