Comments (6)
Would you mind sharing your PostType class and your config/posttypes.php
file with us please?
We can take a look for you @lmartins
from lumberjack.
Absolutely @adamtomat ,
Btw, code is straight from the documentation:
config/posttypes.php
:
<?php
return [
/**
* List all the sub-classes of Rareloop\Lumberjack\Post in your app that you wish to
* automatically register with WordPress as part of the bootstrap process.
*/
'register' => [
App\PostTypes\Product::class,
],
];
app\PostTypes\Product.php
:
<?php
namespace App\PostTypes;
use Rareloop\Lumberjack\Post;
use Rareloop\Lumberjack\QueryBuilder\Post as QueryBuilderPost;
class Product extends Post
{
/**
* Return the key used to register the post type with WordPress
* First parameter of the `register_post_type` function:
* https://codex.wordpress.org/Function_Reference/register_post_type
*
* @return string
*/
public static function getPostType()
{
return 'products';
}
/**
* Return the config to use to register the post type with WordPress
* Second parameter of the `register_post_type` function:
* https://codex.wordpress.org/Function_Reference/register_post_type
*
* @return array|null
*/
protected static function getPostTypeConfig()
{
return [
'labels' => [
'name' => __('Products'),
'singular_name' => __('Product'),
'add_new_item' => __('Add New Product'),
],
];
}
}
Thank you!
from lumberjack.
@lmartins Thanks, I am able to replicate the issue locally. Will have a look at what's causing it 👍
from lumberjack.
@lmartins Looks like it's just an issue with documentation again. Your post type has been registered successfully, it's just not public. That's because register_post_type
apparently sets public
to false
by default: https://codex.wordpress.org/Function_Reference/register_post_type#public
Also, the following line should be removed (unless you're using the Query Builder):
use Rareloop\Lumberjack\QueryBuilder\Post as QueryBuilderPost;
I'll update the docs at some point today. Your final Post Type class should look like this:
<?php
namespace App\PostTypes;
use Rareloop\Lumberjack\Post;
class Product extends Post
{
/**
* Return the key used to register the post type with WordPress
* First parameter of the `register_post_type` function:
* https://codex.wordpress.org/Function_Reference/register_post_type
*
* @return string
*/
public static function getPostType()
{
return 'products';
}
/**
* Return the config to use to register the post type with WordPress
* Second parameter of the `register_post_type` function:
* https://codex.wordpress.org/Function_Reference/register_post_type
*
* @return array|null
*/
protected static function getPostTypeConfig()
{
return [
'labels' => [
'name' => __('Products'),
'singular_name' => __('Product'),
'add_new_item' => __('Add New Product'),
],
'public' => true,
];
}
}
from lumberjack.
Awesome, thanks so much for the feedback @adamtomat !
from lumberjack.
Fixed the documentation.
from lumberjack.
Related Issues (20)
- Wrong class on the WordPress Controllers documentation? HOT 2
- Undefined Illuminate classes
- Custom Taxonomy support in Lumberjack HOT 5
- Enqueue Assets HOT 2
- Popularity HOT 4
- lumberjack-bedrock permission error while cloning Bedrock repository HOT 3
- Lumberjack doesn't see archive-{post_type}.php with proper controller class HOT 4
- Incomplete theme HOT 2
- Request with a dot (".") inside a Custom Route paramter returns a 404 (not found) exception HOT 2
- WooCommerce products in Lumberjack HOT 1
- How can I return a 404 Not Found error from my product controller? HOT 1
- Custom post type translatable labels not working HOT 3
- [bug] site stop working after install wp-browser
- Twig dump error? HOT 4
- QueryBuilder - Collection error after installing Intervention/ImageCache HOT 1
- pass cache time to TimberResponse?
- Access correct pagination information when using the Query Builder HOT 1
- php 8.0.0 not compatible with v4 (composer issue)
- PHP8 Compatibility HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lumberjack.