Blog Settings and Posts

Last edit: 

Contributors: 

Blog settings and posts are fetched with GraphQL queries. The flexibility of GraphQL gives possibility to implement any search functionality you need. Every Custom Attribute added to the fields will be available to add to the installed queries.

Example: Get blog posts GraphQL query

You can fetch blog settings with:

{%- query_graph 'modules/dashboard_blog/get_blog_instance' -%}

You can fetch all post details with:

{%- query_graph 'modules/dashboard_blog/get_blog_posts' -%}

modules/dashboard_blog/get_blog_posts.graphql

query get_blog_posts(
  $per_page: Int,
  $page: Int,
  $title: String,
  $id: ID,
  $slug: String,
  $published_at_lte: String,
  $published_at_lt: String,
  $published_at_gt: String,
  $published_at_gte: String,
  $tags: [String],
  $blog_instance_id: String,
)
{
  customizations (
    is_deleted: false
    per_page: $per_page
    page: $page
    id: $id
    name: "blog_post"
    sort: [
      {
        name: "properties.published_at"
        order: "desc"
      }
    ]
    properties: [
      {
        name: "tags"
        values: $tags
        values_operator: OR
      },
      {
        name: "blog_instance_id"
        value: $blog_instance_id
      },
      {
        name: "title"
        value: $title
      }
      {
        name: "slug"
        value: $slug
      }
      {
        name: "published_at"
        range: {
          lte: $published_at_lte
        }
      }
      {
        name: "published_at"
        range: {
          lt: $published_at_lt
        }
      }
      {
        name: "published_at"
        range: {
          gt: $published_at_gt
        }
      }
      {
        name: "published_at"
        range: {
          gte: $published_at_gte
        }
      }
    ]
  )
  {
    current_page
    per_page
    total_entries
    total_pages
    has_next_page
    has_previous_page
    results {
      id
      user {
        id
      }
      created_at
      author_name: property(name: "author_name")
      blog_instance_id: property(name: "blog_instance_id")
      author_biography: property(name: "author_biography")
      content: property(name: "content")
      excerpt: property(name: "excerpt")
      published_at: property(name: "published_at")
      title: property(name: "title")
      slug: property(name: "slug")
      tags: property_array(name: "tags")
      hero_image: custom_image(name: "hero_image") {
        normal: url(version: "normal")
        thumb: url(version: "thumb")
        transformed: url(version: "transformed")
      }
      author_avatar: custom_image(name: "author_avatar") {
        thumb: url(version: "thumb")
      }
    }
  }
}

Related topics

Questions?

We are always happy to help with any questions you may have. Check out our Help page, or contact us.