This commit is contained in:
2026-01-11 19:39:55 +01:00
commit c1042c9cde
98 changed files with 9086 additions and 0 deletions

20
doc/how-to.tex Normal file
View File

@@ -0,0 +1,20 @@
\chapter{How to ?}\label{ch:how-to}
\section[Create a CPT]{Create a custom post type}\label{sec:create-cpt}
To create a custom post type, you must first register the custom post type as in \WP, then add parameters for the submission page, or even for the \acf fields group.
\subsection[Register the CPT]{Register the custom post type}\label{subsec:register-cpt}
First, you need to register the custom post type in the \dir{src/Registrars/Custom\_Post\_Types} file, in the \lstinline|__construct| method.
\lstinputlisting[label=lst:create-cpt,linerange={$post_types['reviews']-END_CPT_CREATE}]{../src/Registrars/Custom_Post_Types.php}
You must register it like that:
\lstinputlisting[label=lst:create-cpt-example,linerange={1-2}]{examples/how-to.php}
With :
\begin{itemize}
\item \lstinline|<your_cpt_id>|: the ID of your custom post type.
\item \lstinline|<your_cpt_singular_name>|: the singular English name of your custom post type\footnote{This field may be removed in a later version.}.
\item \lstinline|<your_cpt_args>|: an array like the one on \href{https://developer.wordpress.org/reference/functions/register_post_type/}{\lstinline|register_post_type|}.
\end{itemize}