Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #77185

    figu78
    Participant

    Hi,

    I would like to add a custom post type feed in the homepage (NEWS). So my website will have the blog section and another page (HOME) with news.

    How could I do it?? I didn’t find in the VC the way to add a block with a loop of the NEWS custom post type.

    The structure would be:

    ——————————-
    | Menu Header |
    ——————————-
    | Revolution Slider |
    | |
    | |
    ——————————-
    |Custom post feed |
    ——————————-

    Thanks,

    #77368

    figu78
    Participant

    Any Idea?

    #77463

    Kosher K
    Member

    Hi There,

    Thanks for writing in,

    As far as I understand, you are using a third party plugin or custom coded script to have the “News” post type as this doesn’t come bundled with X and not a default feature of wordpress. There’s a “Recent Post” element on visual composer similar to what you are asking but this doesn’t support additional post type you created from a plugin or custom code.

    The best thing you can do is to create a custom query loop for News post type in your child theme functions.php and add it as a shortocode and you can then add it on any page.

    Something like this

    function custom_loop_for_news() {
    	ob_start();
    	query_posts( array( 'post_type' => 'news','order' => 'DESC', 'orderby' => 'date', 'posts_per_page'=> 4 ) ); 
    		if (have_posts()) :
    			while (have_posts()) : the_post();
    				echo '<div class="post-entry">';
    				echo '<h2><a href="'.get_the_permalink().'">' . get_the_title() . '</a></h2>';
    				echo '<div class="entry-content">'. apply_filters('the_content',get_the_content('Read More')).'</div>';
    				echo '</div>';
    			endwhile;
    		endif;
    	wp_reset_query();
    	return ob_get_clean();	
    }
    add_shortcode( 'news-post-type', 'custom_loop_for_news' );

    Then you can add this on your page [news-post-type]

    I hope that helps.

    Cheers

    #77861

    figu78
    Participant

    That’s what I need!

    Thanks!

    #77979

    Christian
    Moderator

    You’re welcome.

    #78281

    figu78
    Participant

    Hello Again,

    One more thing, the demo page of ethos shows different pages with different loops depending on the category.

    I wonder if I could do this way instead of create a custom post type for the homepage. Could I create a category News for the Posts and then show this posts in homepage??

    Home page = Posts category News
    Blog page = Regular posts

    And Could I show News at homepage using masonry and posts at blog page in standard mode?

    Thanks!!
    D.

    #78611

    Christian
    Moderator

    Hey there,

    That is not possible. The blog page displays all categories and you can’t make a category page your home page.

    Thank you for understanding.

    #106502

    Tim M
    Participant

    Hello to all at X Theme

    is there any way i could include a little widget on the front of the rev slider that would show the 2 latest posts from the main blog page?

    my website url http://rsaacademyits.com/rsa-new/

    thanks in advance
    Navneet

    #106524

    Zeshan
    Member

    Hi Navneet,

    Thank you for writing in!

    You can try using our [recent_posts] shortcode to achieve your desired results. You can find demos here: http://theme.co/x/demo/integrity/1/shortcodes/recent-posts

    To add it to the revolution slider, simply create a new layer and add the shortcode as it is inside the layer text. e.g.

    [recent_posts count="2"]
    

    Hope this helps. 🙂

    Thank you.

    #107057

    Tim M
    Participant

    Yes it worked! thank you.

    is there anyway i can edit the style of the how the posts look on the slider using CSS editor?

    thanks
    Nav

    #107064

    Paul R
    Moderator

    Hi Nav,

    Yes you can.

    
    /* background color */
    .rev_slider .x-recent-posts a {
       background: red;
    }
    
    /* title color */
    .rev_slider .x-recent-posts .h-recent-posts {
       color:red !important;
    }
    
    /* date color */
    .rev_slider .x-recent-posts .x-recent-posts-date {
       color: red;
    }
    

    Hope that helps.

    #107095

    Tim M
    Participant

    brilliant, thank you for your support!

    #107110

    Paul R
    Moderator

    You’re welcome Nav 🙂

    #107179

    Tim M
    Participant

    Sorry, me again, is there any way i can create a rollover effect on the posts that appear on the slider, ive used

    a:hover {
    background-color: orange;
    }

    but no luck!

    #107203

    Christopher
    Moderator

    Hi there,

    Please add the following CSS code under Customize -> Custom -> CSS:

    a.x-recent-post3.no-image:hover {
    background: orange;
    }

    Hope it helps.