What is the difference between name vs singular_name in Wordpress? - wordpress

What is the difference between name vs singular_name in Wordpress custom post types? Only name appears to have affect inside CMS.

The singular_name is used for the language in the CMS that should not be plural, whereas name is used for plural language (as you see in most of the CMS).
For example, if you go to Posts > Add New in the admin menu, you will see that the page heading reads "Add New Post".
In the wordpress core, it is using the singular_name to generate the word "Post".
When you add your own custom post type, the singular_name value of your custom post type will be used for the heading when adding a new post of your custom type.
There are also several other places in the CMS that use the singular_name value.
In addition, some themes will use the function get_post_type_labels() to get the singular_name and use it to generate information about what the user is reading. For instance, if your site sells foos and bars you could use the singular_name to generate a button that reads "buy this foo" or "buy this bar" without coding two separate buttons.
To read more about get_post_type_labels() see this page:
https://developer.wordpress.org/reference/functions/get_post_type_labels/
Here is a an example for visual learners:

Related

Wordpress Custom Post Type categroies

I have a custom post type called STORIES.
When a user adds a new STORY, I need them to be able to assign a category (or multiple categories) to the post so I can sort them later by category.
To do this, I only want specific categories I assign to the STORY posts to show - NOT all of the wordpress categories attached to every post type.
For example the default Wordpress category is 'Uncategorized'. How do I remove this category (and any othersI don't want) to ONLY show the ones I select via the custom post type editor?
Is there any way I can make this happen?
I am using custom Post Types UI with Advanced Custom Fields.
You can do that with Post Types UI, You will need to create a new taxonomy.
Here is the screenshot explaining that
https://s.w.org/plugins/custom-post-type-ui/screenshot-4.png?r=1180724
Just fill the text boxes with appropriate names, and check STORY under
"Attach to Post Type" option.
After that you will have custom taxonomy like "Story Category" to use for stories only.

Wordpress custom post type structure

i am building a wordpress website for a client. i need to build 1 template type of page with a list of fields that the client can fill in to populate the page. so lets say i build a template page called Person Template. On it i have an empty picture placeholder on the left and an empty Name Field below that. On the right i have an empty "persons phone number" and "Persons email" field.
what i need to create somehow is a system that the client can enter these 4 items into wp-admin somewhere and save that as a new Person. Then they can repeat and save another Person until they have created say 100 Person pages.
How do I do this? I tried building a Custom Post Type called Person CPT. I have built a Page called Person Template. I have built some "Person CPT" posts and put them on a page but i dont know how to create the Entry Fields page for my client to use.
You're correct that you'll need to use a custom post type. To add the fields you have two options:
Add the fields using add_meta_box(). You'll then need to save this data as post meta. Then in your single-person.php template you would retrieve the meta using get_post_meta(). It's a tad cumbersome, as you need to write the markup for the meta box, hook it into an action to add it to the admin page, and verify the content before it's saved. Here's an article that walks you through it
Alternatively get yourself the Advanced Custom Fields plugin: it makes adding additional fields very quick and easy. I use it all the time.

Is this a good way of setting up a Page that displays team member/staff

I have simple wordpress site that mainly consists of "Pages". One of the "Pages" is called "Our team" and is located http://www.examplewebsite.com/about/our-team.
The "Our team" need to display team members with their names, role, description, photo, etc.
My idea is to set up a "Custom Post Type" called Team with custom fields to capture name, role, photo etc (using http://wordpress.org/plugins/advanced-custom-fields/ to create custom fields).
Then creating a Custom Page Template (http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates) which pulls in data from the "Team" custom post entries and apply this "custom template" to /about/our-team "Page" using the "Template" option on right hand side that appears when editing a "Page".
Question: is above a good way to set-up? If not, can you suggest an alternative please.
Thanks
Yes, the custom post is pretty much the way to go for something like a "Team" page where you are likely to have many Team member specific fields like Title, LinkedIn Profile, Social Profile, Photo etc etc.
In fact many examples that try to show the use of Custom Post Types in Wordpress use this "Team" use-case for showcasing this feature.
Here's a nice example: Creating a "Meet The Team" Page in WordPress.
You maybe able to reuse some of that code for your own purposes too.

Concrete5 Custom Content Types (Blocks)

Is there anywhere online where one can find how to create custom blocks in the same way we can create custom content types in Wordpress. The desired result is to add a block that will allow the user to add/edit custom fields like client name, portfolio description, portfolio thumbnail.
I've created a free tool called "Designer Content" that lets you easily generate these custom blocks:
http://www.concrete5.org/marketplace/addons/designer-content
That being said, it is important to understand this key concept: In Concrete5, everything revolves around PAGES. In general, you want to try to establish an architecture where each piece of data is represented on its own page (a "details" page, which would roughly equate to a single blog post in Wordpress). Then you use the Page List block (usually creating a custom template for it to modify its look) to list out titles, links, and excerpts/photos from each of those "details" pages on a top-level "index" page (roughly equivalant to the home page or category archive in Wordpress).
For example, if you're building a portfolio site, you might want one top-level "Portfolio" page that shows a thumbnail and title of each piece, then a "Portfolio Item Detail" page type that contains one piece per page -- each living underneath the top-level "portfolio" index page.
The benefits of this approach are C5 gives you out-of-the-box tools to manage your "data" (pages) in this way -- users can add, edit, delete, and rearrange the pages via the "Sitemap" in the dashboard. Site search works without any modification -- each page (i.e. portfolio piece) will be its own search result with a link to a specific page. Also you then have more fine-grained control over access permissions if you ever decide to restrict access to only certain groups of people (registered users, etc.).
If you take this approach, you might find the "Page List Teasers" addon helpful (it will let the Page List block -- which you're using for your top-level "index" page -- to show actual content excepts from the pages instead of just a separate "description" field):
http://www.concrete5.org/marketplace/addons/page-list-teasers
Or if you want to dive deeper and customize the page list template even more, I have a starting template with a ton of code comments in it explaining how to do different things here:
https://github.com/jordanlev/c5_clean_block_templates/blob/master/page_list/view.php
But... if you're only talking about small amounts of information and you think a separate page for each one is overkill, then the Designer Content approach I linked to first will work just fine.
You can find a HOW-TO on creating new blocks written by Franz Maruna on the concrete5 website.
Here is the link: Creating a New Block Type
There is also a simple block you can download and install to help you follow the developer tutorials. You can find that here: Simple block template

How to create a simple company blog with a Tag-Cloud in Drupal-6?

I have to create a simple company blog within drupal-6. That means there should be only one single blog each user can post into.
What i have done so far is to create a custom content Type (blog) and a view that displays teasers of the recent blog entries with links to the full blog post.
Now i have to create a Tag-Cloud for this blog.
I created a taxonomy vocabulary for this "blog" content type and set the settings to Tags (Terms are created by users when submitting posts by typing a comma separated list.)
I also installed the Tagadelic Module and created a tag cloud with it, that works great and it displays all the Tags i entered when creating new blog entires.
But now to my problems:
First: If i click on an entry in this tag-cloud the default Taxonomy_term view is used to display the resulting blog entries. Thats bad because i would like to have it displayed the same way as in the view i already defined to show the blogs. Is there a way to use my view to display the results of the tag-cloud?
Second: On my view, below each blog-teaser should be a link to related blog entries (the ones that share the same terms). I do not have a clue how to do that.
is this even possible with the setting i have now or should i maybe take a whole other approach to create that company blog with tag clouds and related blog entries?
You should be able to solve both problems pretty easily, while keeping your current approach:
Take a look at your views list ('admin/build/views/list'). You should see a view called 'taxonomy_term (default)', which is usually disabled by default. This is an optional override of the built in taxonomy term page. You can enable this and configure it to look like the blog view you created.
Alternatively, you could leave that one disabled, but add another display of type 'page' to your already existing blog view, and configure that as an override to the built in taxonomy term. For this you'll need to set the path of that display to 'taxonomy/term/%' and adjust the display to use the term id argument as a filter (look at the above override for how this works).
You could also do it the other way round - use the default taxonomy_term override view, configure its output according to your blog view needs, and add another display for your recent blog entries to that. After this, delete your own blog view and use the new display of the taxonomy term override instead.

Resources