Choose and assign questions (CPT) to quizes

I have created a special type of post (which is also a woo product), named Quizes (post_type => quiz). I also have another CPT, named Questions (post_type => question), which stores a multitude of questions and their multiple choice answers (the latter as their postmeta). As you can guess, the relationship between those two will be many-to-many, meaning that each quiz will have many questions, and each question can be assigned to many quizes... Anyway, what I want is an …
Category: Web

How do I make a request in my browser to search the CPT taxonomy?

How do I make a request in my browser to search the CPT taxonomy? Custom post type "portfolio" Taxonomy "portfolio_entries" Tag "new" The request in the browser of the form site.ru/?s=&post_type=portfolio&taxonomy=portfolio_entries&field=slug&terms=new It does not work, please help me make a correct request. Thanks in advance.
Category: Web

How to set category correctly for a custom post created by a remote API call?

I'm using a plugin - "cleverness-to-do-list" (https://wordpress.org/plugins/cleverness-to-do-list/#description ). I'm aware that the plugin is closed, but I've updated it at my end and gotten it working with my self-hosted Wordpress edition (version 6). I'm trying to create a setup where a remote server calls a webpage on my server and POSTs some data. That custom PHP webpage is configured to create a new ToDo item (which is placed in the posts table). It does that fine except for setting the …
Category: Web

Display and register custom categories for custom post types

Ok here we go. I have 2 different custom post types. The first is called 'portfolio', the second one 'games'. All the game reviews I write are 'games' posts. To have a better overview I created custom categories like reviews, playstation xbox etc. Unfortunately everytime I would like to display the posts of one categorie (http://www.zock-around-the-clock.com/games_category/testcategory) I just get an 404 Error Page. I dont really use the 'portfolio' posts but with them the arrengement into categories would work just …
Category: Web

Restrict Custom Post Type per role in Dashboard

I would like to set up some restrictions on how some roles can access given posts to edit in Dashboard. I have a custom post type affiliates having 2 nested levels. Custom Role User Editor should be able to edit under a level all posts but the normal editor should have access just on items defined by a custom field relation user - post_id Is there an easy way to implement this
Category: Web

How to pass taxonomy terms to WP_Query along with $args?

I created a cpt and custom taxonomy associated with it. Lets say custom taxonomy name is Sports. I added terms to it - football, basketball. Now, i want to fetch post titles tagged under football and basketball separately on same page.(Note:- i am using a custom page template to show list of articles from CPT). $args = array( 'post_type' => 'sports', 'tax_query' => array( array( 'taxonomy' => 'sports_category', 'field' => 'slug', 'terms' => 'football' ), ), ); $myquery = new …
Category: Web

custom taxonomy and custom post type url conflict

i am having one serious url issue. there is news custom post type. it's slug is news. News taxonomy slug: news_category News taxonomy url is: http://domain.com/news_category/press-release i want to change the url of the news_category to news news . so url of news taxonomy would be: http://domain.com/news/press-release i tried to rewrite the slug news_category to news but that's creating conflict issue. news shows news url but all the posts of news post type are returning 404 not found News post's …
Category: Web

creating a custom post template

I want to customize my individual posts. I have an example of what I'm trying to achieve below. Would I make a custom post template for this? If so how would I do this? Or should I add to my single.php? Thanks in advance. What I want my individual post pages to look like. I want two pictures side by side that are the full width of the page. Text. One picture that is the full width of the page. …
Category: Web

Create a Dropdown Selector and Redirect for a Custom Taxonomy in WordPress?

I'm trying to create a dropdown selector on my CPT and CT archive page for a custom taxonomy called "location". I've managed to get the form to submit, however, it does not direct me to the archive page, rather it directs me to a URL that looks something like this https://example.com/?location=11 I'm wanting the destination URL to be this: https://example.com/location/term-name Bare with me as I have no background in Computer Science / IT so I'm learning on my own. Below …
Category: Web

Display category name of custom posts only once in the loop

I have a custom post type called "Projects" and for it some categories. I would like to display the category name of the posts in the loop but only once. I am using this but the category is being displayed on top of every post. For example if the 2 posts are in the same cetegory, now I see the category name twice in the same loop. How can I solve it? My code: <?php $category = the_category(); ?> <h2 …
Category: Web

Bulk Update Custom Fields for Custom Post Types

I am using this function which works great in case anyone wants to bulk update custom fields for custom post types (just change parameters as necessary). $args=array( 'posts_per_page' => -1, 'post_type' => 'mycptype' ); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); $testa = get_field('br_type'); $testb = get_field('br_category'); if ($testa === 'Apples') { update_field('br_featured', '0', get_the_ID()); } endwhile; wp_reset_postdata(); endif; How to use: Insert the code inside your functions.php and refresh …
Category: Web

WordPress import not importing custom taxonomy

I've posted this already in the WP Support Forum hoping to have more luck here. I'm trying to import a custom post type from one blog to another. (126 posts in the custom post type). I've exported using WordPress' export function from WP version 3.3.2 and trying to import into 3.2.1. I can get all the posts to import into the correct custom post type, but none of my custom taxonomy or meta information is being imported in. In both …
Category: Web

Custom post type archive page pagination

I have set up an archive page for my custom post type reference, where I use a query to get all posts of type reference. This works, but when I try to paginate the result, it doesn't work. Right now, it doesn't even print out the pagination links. EDIT: This was earlier used on a regular page, but I changed it to an archive page. That's when the pagination broke. Here is the source code; Custom post type reference (plugin) …
Category: Web

I don't understand why use array inside the add action hook to create custom post type using object oriented way

<?php /* Plugin Name: My Plugin Plugin URI: https://my.plugin.com Description: My plugin description Version: 1.0.0 Author: Me Author URI: https://my.website.com License: GPL2 (or whatever) */ class myClass { function __construct() { add_action( 'init', array( $this, 'create_post_type' ) ); } function create_post_type() { $name = 'Foos'; $singular_name = 'Foo'; register_post_type( $name , array( 'labels' => array( 'name' => _x( $name, 'post type general name' ), 'singular_name' => _x( $singular_name, 'post type singular name'), 'menu_name' => _x( $name, 'admin menu' ), 'name_admin_bar' …
Category: Web

returning the currect URL for nested posts

I have a posttype called (article) witch have a meta_key called (parents_ids). So the article can be related to multiple articles. I want to return the currect URL depending on the parent post For example: 1-If the user click on the child-article comming from parent-article-1 i want the url to be example.com/parent-article-1/child-article. 2-If the user click on the child-article comming from parent-article-2 i want to return the url example.com/parent-article-2/child-article
Category: Web

Add %post_id% to slug of custom post type and prevent the "unique slug" thing that WP does?

I have a custom post type called "equipment". I would like the permalink structure to be: example.com/equipment/%post_id%-slug I specifically want it to use a dash and not a slash (i.e. - "id-slug" not "id/slug"). Every possible solution I've found from googling has used slashes and I just can't get it to work with a dash. I also want to prevent WordPress from adding on the additional number if there's two posts with the same title. Example: example.com/equipment/45-awesomeness and example.com/equipment/46-awesomeness-2 I …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.