Custom-Post-Types | 12 Devs of Xmas article | Content Management System library
kandi X-RAY | Custom-Post-Types Summary
kandi X-RAY | Custom-Post-Types Summary
Custom Post Types article files for 12 Devs of Xmas by Ben Everard.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Custom-Post-Types
Custom-Post-Types Key Features
Custom-Post-Types Examples and Code Snippets
Community Discussions
Trending Discussions on Custom-Post-Types
QUESTION
I am using Contact Form 7 (5.4) and CF7 Smart Grid Design Extension (4.10.0) in a submit form on my WordPress site to construct draft Custom Post Types. The original inspiration for this was this awesome SO post.
The submission form has worked well and reliably for over a year, but with the new CF7 5.4 version, something has changed internally and broken image uploads. All of the other fields have remained unchanged.
The CF7 field with which I am uploading appears as
...ANSWER
Answered 2021-Apr-04 at 11:18Most likely, this issue is the same one I've faced. It appears that the Developer of CF7 decided it was better to make $uploaded_files['something']
into an array. Which probably breaks anyone's plugin that taps into this feature. Not the first time he's changed from a string to an array.
Anyway, this may solve it for you.
Changing this:
QUESTION
I'm honestly getting pretty lost, and could use some guidance to wrap up a project I've been working on
I have a single hierarchical taxonomy, county that I'm using on two of my custom post types, floorplan and ready-made.
I am trying to set up permalinks to the custom taxonomy pages that will display as:
{post-type}/{parent-tax}/{child-tax}
Right now, you can navigate to either or, so floorplans/{parent-tax} and floorplans/{child-tax} will lead to the same county-taxonomy.php template. You can do the same for ready-made/{parent-tax} and ready-made/{child-tax}.
However, if you are going directly through the taxonomy, and you navigate to the child taxonomy, the url will display as county/{parent-tax}/{child-tax}.
What I can't figure out, is how to append the parent taxonomy to the child-taxonomy permalink when you're navigating by the custom post type base. floorplans/{parent-tax}/{child-tax} and ready-made/{parent-tax}/{child-tax} is a 404.
Do I need to write a rewrite rule? I'm kind of at a loss on how to do that. I followed along heavily with this guide in order to get my parent and child taxonomies displaying in the post type permalinks themselves, but the final piece of the puzzle is to be able to navigate to the child taxonomy pages specific to each post type, and include the parent taxonomy in that url.
My rewrite rules as of now look almost identical to the guide I linked,
...ANSWER
Answered 2020-Jul-15 at 16:05to answer my own question,
here is the final rewrite function in order to achieve the desired results:
QUESTION
I'm currently working on a WordPress site and I've created a custom post type called 'events' using the CPT UI plugin.
I want to display the events on my home page, so I've tried to create a loop in my homepage template in the theme files. I've been using this as a guide https://www.wpbeginner.com/wp-tutorials/how-to-create-custom-post-types-in-wordpress/
but for the life of me, I can't get the PHP that is used in that link to work for me.
...ANSWER
Answered 2020-Jul-01 at 13:25You have not end while loop , place this code also
QUESTION
This relates to a post I made here
where initially I was interested in WordPress taxonomies
, but the more I think about my case, the more I think a custom table
approach makes sense.
So I am curious if there are any database experts who can advise me on table structure given my scenario:
I am setting up my site so I can teach guitar courses
. Perhaps of importance, I will not have many courses. Maybe 4-8.
Under a given course
, I have
ANSWER
Answered 2020-May-12 at 22:41These obstacles are intellectual; matters of understanding, not matters of implementation.
Noting the
Relational Database
tag.
Yes, a Relational database will give you:(a) the structure you are seeking, in straight-forward logic, as well as:
(b) the easiest code and the fastest queries
(that which you have requested, plus any that you dream up in the future).
.
But you have to use Relational concepts (the Relational Model by Dr E F Codd).
If you use the concepts marketed by Date; Darwen; et al, which is marketed as "relational", both the structure [a], and the code for navigation and queries [b] will be horrendous. Additionally, you will not have Relational Integrity; or Relational Power; or Relational Speed that is possible in database that complies with Codd's Relational Model.
The Relational Model is Hierarchic.
Three types of Data Hierarchies are formally (by prior intent and design) in the Relational Model.Your requirement is the simplest, four tables in a simple data hierarchy, which is reflected in the Relational Key (more, later).
The second type is a Tree (Single-Parent). You have that in Post, thus it needs no further explanation..
The third type is a Tree for Ancestors and a Tree for Descendants, without duplicating any data. Usually called a Bill of Materials structure. We don't have to worry about that here, it is beyond the scope of the question.
Warning. The links given in the comments will take you down a complex garden path, that might possibly be relevant for the other two types of hierarchies, and in any case, very poor implementations thereof.
Eg. SQL has recursion; MySQL does not have recursion, so a hard-coded and limited method is given).
Eg. some of the methods implement the trees in concrete: if a branch is moved, the entire tree needs to be re-written.
The point is, you don't need it. (You might need it for Post, but not for the answer to your question.)
You have an excellent grasp of your data, which is required for the exercise. But you have fixed ways of thinking about that data, no doubt due to the other implementation methods that you have tried, and the requirements therein. So the demand here is to give those methods of perceiving the data up, and to follow the Relational requirement:
- perceive the data, as data, and nothing but data
No additional columns or structures
To differentiate
Date; Darwen; et al, take the Result Set (the output of a query on Relational tables) as the starting point, as the perspective to be used when analysing and modelling the data. Which is reversing the order of nature, and guaranteed to cripple the modelling exercise (the report you want for a particular purpose vs the data as data).Then, as if stuck in an Excel spreadsheet mindset, they add on a
Record ID
field to the Result Set. Such an act cripples the modelling exercise further, because one now the false notion that a physicalRecord ID
identifies the logical row. It does not.- perceive the data, as data, and nothing but data
If you can give that fixed perspective up, along with the additions that contaminate the problem, and cross over the line into the Relational paradigm:
You will not need the
relations
table: it is totally redundant, because the Relational database supplies all relationships (that you have defined thus far).You won't need the
IDs
, which are always one additional field and one additional index on every file. And the horrendous consequential problems.
Additionally, you will obtain:
- Relational Integrity (which is logical, as distinct from Referential Integrity, which is the physical feature in SQL);
- Relational Power (your navigation and query code will be dead simple,
JOINs
of distal tables will not require intermediate tables to beJOINed
, etc); and - Relational Speed (fewest indices).
If interested, some of my recent Answers contain details and examples of those benefits.
NotationAll my data models are rendered in IDEF1X, the Standard for modelling Relational databases since 1993.
My IDEF1X Introduction is essential reading for those who are new to the Relational Model or Relational data modelling.
Rather than the example data you have given at the top of your question (which is not really example data, but a simple definition of the Form that you would like the display of the data to take), examine the example data (which are, of course, Identifying Keys) that I have given (blue).
- The numbers are redundant. if actually necessary, they can be computed on the fly
- Do not use numbers as Keys, because, when the structure changes, you will have to renumber all your Keys. Totally unnecessary.
The Relational Model demands that the Keys are "made up from the data". The numbers are not.
The data hierarchy is both:
visual in the data model
and reflected in the Relational Keys.
Relational Keys
- are composites, get used to it. SQL has been handling composite Keys since 1984.
- define and implement the data hierarchy. No surprise, because the Relational Model is hierarchic.
Course, Lesson, Topic, Quiz
are Key elements, short names, not necessarily codes (they would be codes in a large university), that are unique in the given context.The
Title
would be the long name that shows up on screens for external users (prospects).A
Lesson
does not exist independently, it exists only in the context of aCourse
. Therefore the Key forLesson
is (Course, Lesson
). AnID
does not uniquely identify aLesson
(or anything else, for that matter). You might have more than oneLesson
across theCourses
.A
Topic
does not exist independently, it exists only in the context of aCourse
and aLesson
. Therefore the Key forTopic
is (Course, Lesson, Topic
). Etc.A
Quiz
does not exist independently, it exists only in the context of aCourse
, aLesson
, and aTopic
. Therefore the Key forQuiz
is (Course, Lesson, Topic, Quiz
). Etc.
Relational Integrity
Eg. A
Quiz
is constrained to a particularTopic
, which is Identified by (Course, Lesson, Topic
).Whereas a
Record ID
based filing system (falsely marketed as "relational") cannot provide that, it can only constrain aQuiz
to anyTopic
.Of course, that applies to all the tables in the data hierarchy.
The relationship between Posts and the structure that is the answer to the question, is not at all clear, therefore it would be incorrect to model it. Nevertheless, it is important to you, so I have modelled it on a possibility basis, with reticence. If you define with more clarity, I will update the data model.
Dead simple, compared to that which you have in the fiddle, or that which is demanded by a Record ID
based filing system.
Get me all lessons for a course
QUESTION
I got this function from a blog (https://tessakriesel.com/learn/how-to-filter-custom-post-types-by-acf-date-field/) but it shows the output on top of the page and not in the element I placed the shortcode. I see a lot it has to do with the echo
. But I don't know how to change my code to the right working one:
ANSWER
Answered 2019-Sep-16 at 13:30You need to use the 'ob_start();' at your function starting and In return function 'return ob_get_clean();' In wordpress this function use for maintain functions sequence in the contains.
QUESTION
What I'm trying to do is generate a new Custom Post Type called report
, add a taxonomy, query the reports, and then generate a shortcode in the format of [report_listing category="general"]
to display the reports in the category General.
Right now, on report/index.twig
, I get a listing of all reports using the shortcode [report_listing]
, and the error No reports available
when using [report_listing category="general"]
.
I am using Advanced Custom Fields, but that doesn't appear to be an issue with this or the rest of the site. The categories are being generated and associated with the posts, since this is a sample {{ dump }}
output on /index.twig
for one report when using [report_listing]
and all reports are displayed:
ANSWER
Answered 2019-Mar-26 at 06:04From reading your current question and code, I can see a few issues. But I'd like to address the shortcode function which is what I think is causing the reports to not get listed by category.
QUESTION
I am using the WordLift plugin for WordPress. I have created a custom taxonomy and I'd like to make it become a Wordlift entity. Is there a way to achieve it?
I've seen this answer for custom post types. Custom post types support in WordLift
...ANSWER
Answered 2018-Oct-03 at 13:11I am currently working on an autocomplete select to use in the taxonomy terms edit screen that would allow you to select an entity from the Vocabulary, thus mapping a taxonomy term to an entity.
Initially I will use this to generate a JSON-LD for the taxonomy term and to provide extensible semantic tagging of posts (e.g. for a LodgingBusiness
entity type which has an amenityFeature
mapped to the taxonomy term, this would allow me to bind the amenityFeature
to well-known knowledge graphs such as DBpedia and Wikidata).
In a later stage the entity page could extend the taxonomy term page and provide automatic suggestion for taxonomy terms when the entity is discovered in texts.
What is your aim exactly, it's would be useful to shape the next releases.
PS: WordLift CTO here.
QUESTION
I am building a mobile app, and I want to use the wordpress.com api to get posts from my wordpress.com site. Normally, you can follow the instructions here: https://developer.wordpress.com/docs/api/getting-started/. However, in this case, the wordpress.com site I am trying to access is set to 'private'.
When I try to make the api get request, I get the 403 error message "User cannot access this private blog".
Is it possible to use the wordpress.com api to load posts from a private wordpress.com blog?
I am hopeful this is possible when someone controls the app making the api request and also controls the target private site (like in the case here). This seems like a good use case for the api.
I don't want to change the site from being private for now. I also don't want users of the app to have to enter log-in credentials anywhere. I want the app itself to be able to provide the relevant credentials when loading posts.
I have gone through various oauth actions, such as getting a client_id, client_secret_key, and a token, but I don't see any method for actually loading posts from a private site.
I have seen the question asked before, without answer, like: https://wordpress.stackexchange.com/questions/180637/fetching-private-posts-or-custom-post-types-via-wp-api-with-basic-authentication and How to retrieve private posts from wordpress using JSON rest api?.
...ANSWER
Answered 2018-Feb-02 at 18:26I was able to (mostly) figure this out. Yes, it is definitely possible to use the wordpress.api to load posts from a private wordpress.com site.
In order to do this, any api call you make to the private site (get, post, etc...) needs to have an oauth2 token in the header along with the request. You get the token from wordpress.com.
Note that this description is about the wordpress.com api, not the wordpress.org api.
To get that token, you can follow the steps here: https://developer.wordpress.com/docs/oauth2/. You can potentially get a short term token that needs to be refreshed regularly or a permanent token. You get the permanent token from the server-side code method.
There are a few different ways to do that:
All of them require that you register a separate url with wordpress.com, here: https://developer.wordpress.com/apps/. At that site, you create a new "app" that will ask for permission. The app can use your url if you have a website, or just the localhost site you use in development (or even just a localhost port url if you don't use it in development--the key is to get a client_id and use it in the request process). There, you will get a client_id and client_secret_code that you will need for these steps. From there:
1) You can just use curl code to query the api and get back an auth code, and then another query with that auth code to get a token. Note that the curl code on the wordpress.com oauth2 documentation is in PhP (not pure curl).
2) You can provide the methods to get the token, as described in the wordpress oauth2 doc linked above, in your app directly. For ionic apps, this probably requires using an inappbrowser plugin, to go to the page where the api app gives you permission.
3) Another possibility: wordpress set up a fairly simple node-based process to get a token: go to https://github.com/Automattic/node-wpcom-oauth, download the code there, and follow the steps. A very helpful tutorial on that is at:http://haiku2.com/2015/11/how-to-setup-a-wordpress-com-oauth-token/. It is a few years old but it still works as of now.
Once you have a token, you include it in the header to make the call. For example, using HttpClient from @angular/common/http (for ionic/angular/typescript apps):
QUESTION
I want to make custom post types in my Wordpress site. I started it based on this two articles: Custom post type, Site specific plugins
My code is so far:
...ANSWER
Answered 2018-Jan-05 at 20:20The __()
function is just a translator. See WP's function reference. So, to continue making it translatable, change the text domain (aka twentythirteen
) to be wherever the translation should be found. In your case mysite-core
. This is best practice so that your plugin can be internationalized in a standard way. See here.
QUESTION
I have created my Post Type, but I dont know what I have done wrong that archive.php shows all posts instead of archive-gallery.php. Here is the code.
custom-post-types.php
...ANSWER
Answered 2017-Aug-23 at 19:13You have a typo in your gallery when you register it:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Custom-Post-Types
PHP requires the Visual C runtime (CRT). The Microsoft Visual C++ Redistributable for Visual Studio 2019 is suitable for all these PHP versions, see visualstudio.microsoft.com. You MUST download the x86 CRT for PHP x86 builds and the x64 CRT for PHP x64 builds. The CRT installer supports the /quiet and /norestart command-line switches, so you can also script it.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page