Composables

Nodes

Generated composables to fetch Nodes and their content

useNodeByUri

a usefull composable if you want to fetch content by uri, regardless whether it's a page or post type in WordPress.

const { 
data
:
node
} = await
useWPNodeByUri
({
uri
: 'slug' })

an example how to use this for a [...slug].vue page:

const 
route
=
useRoute
()
if (
route
.
params
?.
slug
&&
route
.
params
.
slug
[0]) {
const {
data
:
currentNode
} = await
useWPNodeByUri
({
uri
:
route
.
params
.
slug
[0] })
}

Copyright © 2024 WPNuxt