In tumblr, show only posts with a certain tag in the home page

后端 未结 8 501
忘掉有多难
忘掉有多难 2021-01-03 03:56

In tumblr, is it possible to show only posts with a certain tag in the home page?
If so, how is it done?

相关标签:
8条回答
  • 2021-01-03 04:27

    I have tried many ways to do this, using tumblr php api and other, This worked for me: I am using a page outside tumblr and loading the tagged posts via curl php calls. It can be done via ajax but for SEO reasons I wanted to use php. Here is the code:

    $oath = 'xxx';
    $blogName = 'yyy.tumblr.com';
    $tag='tagname';
    $apiLink = "http://api.tumblr.com/v2/blog/$blogName/posts/?api_key=$oath&tag=$tag";
    
    
    
    
    // Initializing curl
    $ch = curl_init( $apiLink );
    
    // Configuring curl options
    $options = array(
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => array('Content-type: application/json') ,
    );
    
    // Setting curl options
    curl_setopt_array( $ch, $options );
    
    // Getting results
    $result =  curl_exec($ch); // Getting JSON result string
    
    $data = json_decode($result);
    
    
    $posts = $data->response->posts;
    
    0 讨论(0)
  • 2021-01-03 04:30

    I just wrote up the solution to the opposite problem here:

    • How to hide the posts with a given tag from the homepage.

    You can take inspiration from there and implement the opposite. Alternatively, you can simply add a "hidden" tag to each one of the things that you don't want displayed on the homepage.

    0 讨论(0)
提交回复
热议问题