We're merging with GenerateBlocks! Learn more here.

[Support request] fetching custom post type

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support fetching custom post type

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #29975
    Michelle
    Participant

    I’d like to achieve this effect: https://sebastianfoster.com/artists, and was told it could be done with a bit of coding. Can someone help me with this?
    I can create the post in any format, as long as we can get it to appear in the sidebar, or in a column of it’s own. Currently, these are product categories.
    Thanks!
    Michelle

    #30045
    elvin
    Moderator

    Hi there,

    I remember answering this question.

    And sorry about this but I believe I missed the context when I answered it. I thought the names of lists were posts lists of artists rather than a listing of categories.

    WPSP plugin can’t list categories directly. My bad. If you bought the plugin for this, you can ask for a request for a refund.

    But to help you out here’s something worth a try:

    Before you start, here are things to consider:

    Are the place labels going to be a taxonomy as well?

    If it isn’t, you’ll need ACF or some sort of custom fields plugin to save the places associated with the artist name.

    You then create your custom shortcode for this:

    Example: A custom category listing with artist_location field displayed on the side.

    add_shortcode('category_listing','category_listing_with_location');
    
    function category_listing_with_location(){
    echo '<ul class="category-list">';
    	
    $categories = get_categories( array(
        'orderby' => 'name',
        'order'   => 'ASC'
    ) );
     
    foreach( $categories as $category ) {
    	$acf_id = 'category_'.$category->term_id;
    	
        $category_link = sprintf( 
            '<a href="%1$s" alt="%2$s">%3$s</a> <span class="artist-location">%4$s</span>',
            esc_url( get_category_link( $category->term_id ) ),
            esc_attr( sprintf( __( 'View all posts in %s', 'textdomain' ), $category->name ) ),
            esc_html( $category->name ),
    				get_field('artist_location',$acf_id),
    			
        );  
        echo '<li class="category-list-item">' . $category_link . '</li> ';
    }  
    echo '</ul>';
    
    }

    This is a PHP snippet – here’s how to add one – https://docs.generatepress.com/article/adding-php/

    Note: we may need to style it with CSS to remove li styling.

    example:

    ul.category-list  {
      list-style: none;
    }

    Again, my bad.

    #30085
    Michelle
    Participant

    Hi Elvin!

    Thanks so much for your reply! I can make these anything. They don’t have to be product categories. Should I make each artist a post? We can tackle the artist location later!
    I’m guessing these will popup/appear in the sidebar? Can you point me in the direction of the instructions for this?

    Thanks!
    Michelle

    #30095
    elvin
    Moderator

    Thanks so much for your reply! I can make these anything. They don’t have to be product categories. Should I make each artist a post? We can tackle the artist location later!

    No need to change that. In fact, I think that’s already good. That’s how I’ll actually do it if it were up to me.

    I’m guessing these will popup/appear in the sidebar? Can you point me in the direction of the instructions for this?

    The PHP snippet I’ve provided allows you to use the shortcode [category_listing] which will display the category links + the ACF value for its location label.

    For this one, you can use it on any part of the site where shortcodes can run.

    Note: As for ACF, please refer to this – https://www.advancedcustomfields.com/resources/adding-fields-taxonomy-term/

    Here’s how to add PHP snippets – https://docs.generatepress.com/article/adding-php/

    #30142
    Michelle
    Participant

    Hi Elvin!
    I know just enough to mess this up. Can you email me privately? I’ve read on other topics there is a form or box for private information, but I can’t locate it.
    Thanks!
    Michelle

    #30151
    elvin
    Moderator

    I’ve read on other topics there is a form or box for private information, but I can’t locate it.

    GP support forums got one. This one doesn’t.

    You can send us an email through our contact page if you prefer that. https://wpshowposts.com/contact/

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.