Trying to sort and display categories(not posts) by custom field: 'order'

I'm a WordPress rookie. I've added a custom field to my "Category" taxonomy. The custom field is "custom_order" and its purpose is to hold a number so that my categories can be sorted and displayed in the order I choose. My problem is that I can't get them to sort; I can display the categories, and 'echo' each category's "custom_order" number, but I must be missing something when it comes to accessing and sorting the meta_value. Not sure if I'm …
Category: Web

Performance bug - slow DB query

Since 2017-09-26 I have terrible problems with performance on my website. Loading single post or any other page takes even 20s. I've been debugging it it found out, that the problems are DB queries. For example this one is executing almost with every page load and takes about 36s: SELECT t.*, tt.*, tr.object_id FROM az2_terms AS t INNER JOIN az2_term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN az2_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('znacka', 'model') …
Category: Web

Save an array of values in the post meta box

I created box meta for a custom post type. From the admin edit for the post, I want to enter in multiple values so that it saves as an array so I can then call it as an array from the front end. So in my meta box from the admin edit I'd save the values "200", "201", "202" in a single field "_parent_id" and then grab it from the front end $array = get_post_meta($postID, "_parent_id", false); How should those …
Category: Web

I cannot get tax_query in get_posts() to work with custom taxonomy

I have been trying to achieve this for the past two days but nothing works. I am attempting to build functionality to search any post, page, and a couple other custom post-types by a tag. I have created a plugin which registers a taxonomy called search_tag. search-tags.php require_once __DIR__ . '/includes/search-tags.class.php'; function search_tags_closure() { $search_tags = new Search_Tags; $search_tags->create_taxonomy(); } add_action('init', 'search_tags_closure'); search-tags.class.php class Search_Tags { const NAME = 'search_tag'; const LABEL = 'Search Tags'; protected function get_post_types() { $args …
Category: Web

WP Container Displaying Only on First Page of Archive

I have the following code for a two-column container: <div class="rh_content rh_content_above_footer rh_page__content"> <div class="wp-container-3 wp-block-columns"> <div class="wp-container-1 wp-block-column"> <h2 style="font-size: 19px;color: #36a8fc;">Trouvez à Altea l’appartement répondant à tous vos critères</h2> <p>Souhaitez-vous une, deux ou trois chambres ? Plutôt vue sur l’extraordinaire arrière-pays, ou sur la mer ? Votre rêve, c’est plutôt terrasse ou jardin privatif ? Et côté architecture ? Votre préférence va-t-elle vers le style méditerranéen typique, ou vers une architecture résolument moderne ? Comme vous le voyez, de nombreux choix sont possibles.</p> …
Category: Web

AJAX not Working with php as supposed

I am creating a like system in PHP . My code looks like this . <?php class Like_System { private $userid; private $postid; private $user_ko_like_count; private $post_ko_like_count; private $user_ko_dislike_count; private $post_ko_dislike_count; private $user_ip; public function __construct(){ } public function our_ajax_script(){ wp_enqueue_script( 'sb_like_post', get_template_directory_uri().'/data/js/post-like.min.js', false, '1.0', 1 ); wp_localize_script( 'sb_like_post', 'ajax_var', array( 'url' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'like_system' ) ) ); } public function load_our_ajax_script(){ add_action( 'init', array($this,"our_ajax_script") ); add_action( 'wp_ajax_nopriv_like_system',array($this,"like_dislike_kernal")); add_action( 'wp_ajax_like_system',array($this,"like_dislike_kernal")); } public function verify_nonce($nonce){ if …
Category: Web

Installing WordPress to root directory with existing static site. Concerns?

I’d like to update a simple static HTML site to WordPress. This would be my first WP site and I already have a theme in mind to use. The static HTML site has seven pages and an images sub folder in the root directory. My current thinking is to install WordPress into the root directory that the current static HTML site resides in, build it in the background and delete the old site(static HTML) when the WP site is ready …
Category: Web

Using wp_list_table how to trigger update function "inline"?

Ok, i have used wp_list_table to read data from a custom db table and i like to be able to update the database table by clicking the correspondig cell. Defaults are 0 and when clicked the value is set to 1. so by clicking the cell updateVisitor() will be triggered "inline" my function which i isn't part of the Visitors extend WP_list_table class function updateVisitor($id){ global $wpdb; $query = $wpdb->prepare( "UPDATE tbl_visitor SET visitorPayed =BINARY(visitorPayed=1) WHERE visitorID = %d", intval($id) …
Category: Web

Replase post title based on conditions

So I would like to replace the entire title of posts in WordPress bases on user behaviuor and role. Please note that I would like to replace the entire post title and not the prepend or append text to it. Each post has a 'default' title, which is the title of the post, like "Make No.1245/12.02.2022 on model 2376/2021". The alternative title would be "Make No.*******/********.2022 on model *******/2021" basically replacing certain parts of the title with asterisks, essentially hiding …
Category: Web

How do I fix the 403 error for wp-admin/admin-ajax.php?

When I use the Safari console, I always get the following notification: failed to load the resource: the server responded with a status of 403 for wp-admin/admin-ajax.php Does anyone know how to fix this? I've already checked the file permissions. These work out fine so far.
Category: Web

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

admin-post.php results on white screen after form submission

This is a strange error because it wasn't happening earlier, it was actually all working fine. I have removed all the code I have added since I last tested it and it was working before it broke. I have a custom post acting as a page to submit a form on and I am processing the form via a function in the functions.php page in my plugin. function tm_add_new_job() { if ( empty($_POST) || !wp_verify_nonce($_POST['tm_add_new_job'],'tm_add_new_job') ) { wp_nonce_ays(); die(); } …
Category: Web

Link post to blog from a static page

I'm a WP rookie, and I just designed a static homepage that shows the 3 most recent posts in my database. I would like to redirect the user to another page in order to show him the entire blog post everytime a post title gets clicked. I already created my blog page using the reading settings menu but I can't figure out how to link each post to my blog page and show it's content on it. Any indications?
Category: Web

Every time i create new post id="WRWHOISInstalled" is in the html wordpress editor

Everytime i create a new post there is a code in the editor when i view it in html mode i see this code; <div id="WRWHOISInstalled" style="display: none;"></div> there wasnt this problem before it happend automaticly by itself? i tried searching it on the internet but i didint find anything please help :( Note im using classic editor
Category: Web

Passing variables in the permalink structure on a custom post type

I have a structure like this for my custom post types: domain.com/member/member-name/book/book-name Basically, I have a custom post type of member, and the member-name is the post. What I want to do is pass a variable called books, but I can't get my code to work. I've based my solution on one that has previously been asked on here but my structure is different, and I've googled and googled to no avail. I really cant get my head around rewrite …
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 retrieve attachments from child pages of a specific Page?

How would I retrieve attachments from all subpages of a specific Page ID? Example: SPECIFIC PAGE Child (with attachments) Child (with attachments) Child (with attachments) I'm currently using this code to retrieve all attachments site-wide, however I would like to limit this to only pull images from all children of a specific Page. $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => null ); $attachments = get_posts( $args ); if ( $attachments ) { foreach …
Category: Web

ACF Relationship - Get Parent's Post Object

I've a few post that have ACF relationship field set up : - Post A - Post A1 - Post A2 - Post A3 Post A have a relationship that link to : Post A1,A2 & A3... Post A1,A2,A3 have their own post templates, But inside the post templates, can I manage to get Post A's Title? Because I don't want hardcoded Post A's title on Post A1,A2,A3's fields. I'd tried this solution, but seems can't retrieve parent A's post …
Category: Web

About

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