text
stringlengths
12
210k
meta
dict
Q: Rest API nonce is being cached I'm building a custom Rest Api endpoint. User can call this endpoint via ajax request in the frontend together with nonce value which was created by wp_localize_script( 'some-js', 'wpApiSettings', [ 'nonce' => wp_create_nonce( 'wp_rest' ), ], ] ); The problem is the caching plugin. In my case, I've used breeze. It cache the page together with nonce value. When the nonce is expired, the page cache still have the expired nonce in it. So when the used this nonce, they receive rest_cookie_invalid_nonce until the cached is cleared. Is there a way to prevent this from happen?
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414230", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Editing Inline fonts/typeface using the block editor I am attempting to modify the typeface when using the block editor. I see it is possible to change the colour of a single word/letter using the 'highlight' option found in the caret menu: In the editor, you do have the option to change the typeface but this will change the type of the entire block. Not a single word/letter. Using theme.json I have added a custom colour palette which is then shown in the 'highlight' option, so I thought as a workaround I would add a similar brand colour selection, but this time for an alternate/serif typeface. This would give me a class name to grab hold of and attatch the alternate typeface. However, the editor appears to take the colour value as it's reference. So if I make a brand1 with a colour value of #161616 and a brand1serif with the same colour value, the front-end appears to ignore the serif version and thinks it needs to display brand1, instead of brand1serif // theme.json "color": { "palette": [ { "slug": "brand1", "color": "#161616", "name": "Brand 1" }, { "slug": "brand1serif", "color": "#161616", "name": "Brand 1 Serif" } ] }, When 'Brand 1 Serif' is selected in the editor, this is what the front-end displays. My expectation was that it would add a class has-brand-1-serif-color: <mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-brand-1-color">WordPress</mark> Has anyone been able to change the typeface of a single word/letter through the native editor functions (i.e. not custom HTML editing)?
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414233", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Why is my activator class adding the files/running the actions I add? I am using the WP Plugin Boilerplate to develop a plugin, but when I activate the plugin, the require files and actions I put inside the activate() function are not working. I have tested the class and method by using die('Plugin error') and it should this message so I am not sure as to why the the other statements aren't working. There is also no PHP error being thrown. class Wp_Portfolio_Pro_Activator { /** * Short Description. (use period) * * Long Description. * * @since 1.0.0 */ public static function activate() { // Require Kirki and setting for plugin build on framework. self::load_files(); add_action( 'admin_notices', array( __CLASS__, 'admin_notice' ) ); } public static function admin_notice() { $message = '<div class="notice notice-success"><p>'; $message .= sprintf( __( 'Hello %s!', 'my-plugin' ), '<strong>' . get_current_user_name() . '</strong>' ); $message .= '</p><p>'; $message .= __( 'Thank you for downloading WP Portfolio Pro. Edit the setting from the customizer.', 'wp-portfolio-pro' ); $message .= '</p>'; $message .= '<a href="' . esc_url( admin_url( 'customize.php?customize_changeset_uuid=' . get_theme_mods_changeset_post_id() ) ) . '"><button>Go to settings</button></a></div>'; echo $message; printf( '<div class="notice notice-success is-dismissible">%1$s</div>', $message ); } public static function load_files() { // Require Kirki and setting for plugin build on framework. require_once plugin_dir_path( __FILE__ ) . 'includes/kirki/kirki.php'; require_once plugin_dir_path( __FILE__ ) . 'includes/wp-portfolio-pro-kirki.php'; } } This is the code in the main file that calls the class and runs the activate method: /** * The code that runs during plugin activation. * This action is documented in includes/class-wp-portfolio-pro-activator.php */ function activate_wp_portfolio_pro() { require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-portfolio-pro-activator.php'; Wp_Portfolio_Pro_Activator::activate(); } register_activation_hook( __FILE__, 'activate_wp_portfolio_pro' ); A: You code is almost certainly loading those files and adding the notice, but you've misunderstood how PHP works so they're not happening when you expect them to happen. You need to keep two things in mind with PHP: * *Admin notices and require_once are not persistent across multiple requests. If you want to load a file or display a notice you need to run that code for every request for which you want the notice to appear or the files to be loaded. *Your plugin code will run for every page request in the browser, but the activation hook will only run once: when the plugin is activated. So keep those in mind when you consider the sequence of activating a plugin through the UI: * *You visit wp-admin/plugins.php and click Activate on a plugin. *You are taken to /wp-admin/plugins.php?action=activate&plugin=plugin-name.php, where the plugin is activated. *You are redirected back to to /wp-admin/plugins.php?activate=true. Your activate() method is only going to run for step 2. This means that the framework you're trying to load is only going to load during step 2, and your notice is only going to be during step 2. So you need to do 2 things: * *Run load_files() on every request. In the WP Plugin Boilerplate there is already a load_dependencies() method of the Plugin_Name class that seems to be intended for loading files. *Run your add_action() for admin_notices on every request. In the boilerplate the define_admin_hooks() method of the Plugin_Name class seems the appropriate place for this. In your admin_notices method you will need to implement logic to hide the notice if it's been dismissed.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414236", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "1" }
Q: Why after customizing Home Page, the site is loading six missing blob sources, slowing down all site? GET blob:http://www.mywebsite.it/cb7bb04e-9872-4165-b31e-c6686ee64947 net::ERR_FILE_NOT_FOUND This is what I see at the end of the loading of the page in the network console. There are six of these requests failing and the website loading is super slow, I am talking about 20 seconds. It started to happen, after I customized the HomePage via the Aspect Customizer of the website, removing Categories, Archive, Last 5 articles and Search default blocks. Currently I'm using a random template found on internet, called Varia. Any ideas? Or any suggestions to fix it?
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414240", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Get approved comments or comments that the author is me This is how we can get the approved comments. $comments_query = new \WP_Comment_Query([ 'status' => 'approve', ]); And this is how I can get my comments. $comments_query = new \WP_Comment_Query([ 'author__in' => [get_current_user_id()], ]); How can I do an OR of these queries in one query?
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414241", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: What is wrong with my sorting logic? Trying to sort a custom query. I need the values to be sorted based on the menu order. The following code prints out all the values as expected, but not in any sorted order. I'm trying to get the integer values sorted foreach ($questions as $question){ $values = array ( get_post($question->ID)->menu_order ); sort($values); foreach($values as $value){ echo '<br>' . $value; } }
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414242", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Could a very long article slow down all website and wpadmin? There is this article in the wordpress website that counts: * *words: 8207 *characters: 56302 *estimated reading time: 43m *20 images and 183 paragraphs and 201 blocks. Could affect loading time of every page, including the wp-admin? A: Wordpress depends more on the efficiency of the code that queries the database, and the templates in the theme that display the pages. And external requests (off site) And large images. And more. The best way to find slowness is via the Developer tools in your browser (usually via F9). The Network tab will show you the timings on all of the requests for a page. You can then look for slow request responses. To check your theme's efficiency with database queries, use the "Query Monitor" plugin. Lots of good info found by that plugin.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414243", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: How to limit number of posts in the certain category and exclude the oldest post automatically I would like to have a php code which will exclude the oldest post from the certain category of certain taxonomy if total number of posts in this category (in the time of adding a new post) greater than X. E.g. I have taxonomy 'post_importance' and category in it with terms 'featured'. I already have 3 posts in category 'featured' and I am adding the fourth one. I want that after that the oldest post in category would be excluded from it. How to do it (sorry I have no expertise in php whatsoever, just html/css) :( Thanks.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414247", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Use Base-URL with Query-Loop I've set the Base-URL for my WordPress page with <base href="https://www.example.com/" /> function custom_header_metadata() { ?> <base href="<?php echo get_site_url(); ?>"> <?php } add_action( 'wp_head', 'custom_header_metadata' ); When using the navigation for a query block I will now get redirected to https://www.example.com/?query-15-page=2 and not the second page of the query. This is the Block, I used on the page to display the posts. I need the base-Tag to use the One-Page-Navigation on every site (change site and scroll to the clicked location). https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base?retiredLocale=de Do you know a solution for that problem? My current solution is to remove base and add the following javascript. document.body.classList.contains("home") ? ($navigationLinks[0].className += " active") : $navigationLinks.forEach(function (element) { let old_link = element.getAttribute("href"); element.setAttribute("href", "/" + old_link); }); Cheers, Marcel
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414250", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: I need help with CPT for a food delivery business We have a food delivery service company, and work with woocommerce for the website We wanted to start a brand new website with CUSTOM POST TYPES so that each restaurant has its menu displayed. What we need working is basically for this screenshot (Screenshot 1) to be fully built with CPT using elementor. We have our own website team but dont have enough knowledge in certain CPT functions and the best way to do the tasks Each time we want to add a new restaurant, i want it to have all of the details prebuilt in a CPT page, we have already tested as you can see in the following screenshot (Screenshot 2), this page would have to be amplified, so that the navigation bar with the menu categories anchors to the menu products of that category (Screenshot 5). Each restaurant has a different amount of categories, we dont know if the best way is to use repeaters or a different method, but the repeater for us doesnt seem to be working. We have our own plugin to display the products in this way, it just needs to display the shortcode. (Would be great but it is not mandatory) What would also be great is for the CPT page to include the opening and closing hours of the restaurant, so that in the main page (Where it has the list with all of the restaurants) has the restaurants displayed in a way where when the restaurant is open, for it to appear at the top of the list in normal color (Screenshot 3), and once the restaurant closes, for it to appear at the bottom of the list, and to appear greyed out, and display “Closed”, in the corner, (Screenshot 4). I hope you understand what i am talking about, and maybe there is an easier way to build what we are looking for, we can help in any way and do a call. If you have any questions please let me know. Thank you
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414254", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Remove 'default' font option from Gutenberg typography settings I've added my own font to the theme that I'm working on with the help of the theme.json file like this: "typography": { "customFontSize": true, "customLineHeight": true, "fontFamilies": [ { "fontFamily": "'Mulish', sans-serif", "name": "Mulish", "slug": "mulish", "fontFace": [ { "fontFamily": "Mulish", "fontWeight": "400", "fontStyle": "normal", "fontStretch": "normal", "src": [ "file:./assets/fonts/Mulish-VariableFont_wght.woff2" ] } ] } ] }, When editing a block which support typography settings the custom font is shown. But by default content is shown in the 'default' style which is plain 'serif'. When changing it to the custom font it shows the custom font in the editor. I can't find a way to remove the 'default' font option and to show the content in the editor by default with the custom font. When searching for a solution I found this article (https://www.paulchinmoy.com/change-gutenberg-editors-default-font/) but that feels like a hack. And only works when you use a single custom font. Is there a way to remove the default setting and styling of content in the block editor? And only use the custom font(s) which are used in the theme.json file? A: You haven't set the font in the block editor, instead you've added an additional font family option! Instead use global styles instead to style the text: { "styles": { "typography": { "fontFamily": "'Mulish', sans-serif" }, } } Now the default will be Mulish, additionally setting fontFamilies to [] in the typography section will remove the font family picker
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414256", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "1" }
Q: weird Internal Server Error - no error log produced I'm facing a weird issue with a Wordpress installation and I'm not sure how to proceed further. I've developed a simple AJAX endpoint only available for logged in users, which returns the details of a custom post type associated with the user. Example: function get_return_request_detail() { $returnRequestId = (isset($_POST['return_request_id'])) ? $_POST['return_request_id'] : ''; if(empty($returnRequestId)) { echo json_encode("missing parameter"); wp_die(); } $results = get_post_meta($returnRequestId); $meta = unserialize($results["_meta"][0]); if($results["_field_user_id"][0] == get_current_user_id()) { ... logic ... echo json_encode($data); } else { echo json_encode("unauthorized"); } wp_die(); } add_action('wp_ajax_get_return_request_detail', 'get_return_request_detail'); The endpoint works fine and I retrieve the data correctly. An example on how I call it: jQuery.ajax({ type: "post", dataType: "json", url: "/wp-admin/admin-ajax.php", data: { action:'get_return_request_detail', return_request_id: id, }, success: function(response) { console.log(response); }, }); The problem is that as soon as I switch to another page the whole front-end starts returning an error: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error. More information about this error may be available in the server error log. Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request. I've tried enabling both debug and debug_log but I still receive the same message with nothing being written in the log. To enable it I've just added in the wp-config.php: define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true ); define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', true ); The weird behaviour is that, in order to make the front-end work again, I just need to visit an Admin page and the error disappears. My questions are: * *Is there any way to have a more detailed error log for this issue? *Do you have any idea on what could be possibly causing it? Something related to admin-ajax? What I've tried so far, with no results: * *Check Wordpress core file permission; *Replace core files with a fresh installation; *Followed this answer in order to enable error logging for admin-ajax.php (no results); *Disable caching / security plugins; *Disable Server Side caching (Dynamic Cache & Memcached); *Check error logs on Server (the error produces no log); Thanks A: I've found this question which describes the same issue i'm facing. The accepted solution didn't work for me, but after a bit more research I've found this solution from WPML. I've noticed that after calling the endpoint the .htaccess was getting rewritten, this part: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteRule ^en/wp-login.php /wp-login.php [QSA,L] RewriteRule ^fr/wp-login.php /wp-login.php [QSA,L] RewriteRule ^de/wp-login.php /wp-login.php [QSA,L] RewriteRule ^it/wp-login.php /wp-login.php [QSA,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> Options -Indexes gets rewritten as: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase /it/ RewriteRule ^index\.php$ - [L] RewriteRule ^en/wp-login.php /it/wp-login.php [QSA,L] RewriteRule ^fr/wp-login.php /it/wp-login.php [QSA,L] RewriteRule ^de/wp-login.php /it/wp-login.php [QSA,L] RewriteRule ^it/wp-login.php /it/wp-login.php [QSA,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /it/index.php [L] </IfModule> Options -Indexes After applying the suggested solution from WPML: add_filter('mod_rewrite_rules', 'fix_rewritebase'); function fix_rewritebase($rules){ $home_root = parse_url(home_url()); if ( isset( $home_root['path'] ) ) { $home_root = trailingslashit($home_root['path']); } else { $home_root = '/'; } $wpml_root = parse_url(get_option('home')); if ( isset( $wpml_root['path'] ) ) { $wpml_root = trailingslashit($wpml_root['path']); } else { $wpml_root = '/'; } $rules = str_replace("RewriteBase $home_root", "RewriteBase $wpml_root", $rules); $rules = str_replace("RewriteRule . $home_root", "RewriteRule . $wpml_root", $rules); return $rules; } I can see that the values for RewriteBase / and RewriteRule . /index.php [L] don't get updated anymore and the Internal Server Error disappears. In my case I guess the issue was caused by developing the website in a language and then changing it and transferring the website. I'll contact WPML to let them know about the issue, also I still don't get what's causing the rewrite of the .htaccess after calling the endpoint.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414258", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Link on post title only if post have content Hello i create an archive.php custom for category-id (category-id.php) and use this code <?php /** * A Simple Category Template */ get_header(); ?> <section id="primary" class="site-content"> <div id="content" role="main"> <?php // Check if there are any posts to display if ( have_posts() ) : ?> <header class="archive-header"> </header> <?php // The Loop while ( have_posts() ) : the_post(); ?> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <div><p> <?php if( get_field('telefono') ): ?>Telefono: <?php the_field('telefono'); ?> <?php endif; ?> <?php if( get_field('email') ): ?> Email <?php the_field('email'); ?> <br /> <?php endif; ?> <?php if( get_field('indirizzo') ): ?> Indirizzo: <?php the_field('indirizzo'); ?> <br /> <?php endif; ?> <?php if( get_field('link_mappa') ): ?> <a href="<?php the_field('link_mappa'); ?>" target="_blank" rel="noopener noreferrer"> <img src="https://www.mondosup.it/wp-content/uploads/link_mappa_scuole_sup.png" width="250" /></a> <?php endif; ?> </p> </div> <?php endwhile; else: ?> <p>Sorry, no posts matched your criteria.</p> <?php endif; ?> </div> </section> <?php get_sidebar(); ?> <?php get_footer(); ?> I display under title ACF field. Now i'd like to put link on single post only if the post have content. I try with some code but i cant'do that..is possibile? A: Based on this question Probably the easiest way would be: <?php // The Loop while (have_posts()) : the_post(); ?> <?php if ('' !== get_post()->post_content): ?> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <?php else: ?> <h2><?php the_title(); ?></h2> <?php endif; ?> <div><p> <?php if (get_field('telefono')): ?>Telefono: <?php the_field('telefono'); ?> <?php endif; ?> <?php if (get_field('email')): ?> Email <?php the_field('email'); ?> <br/> <?php endif; ?> <?php if (get_field('indirizzo')): ?> Indirizzo: <?php the_field('indirizzo'); ?> <br/> <?php endif; ?> <?php if (get_field('link_mappa')): ?> <a href="<?php the_field('link_mappa'); ?>" target="_blank" rel="noopener noreferrer"> <img src="https://www.mondosup.it/wp-content/uploads/link_mappa_scuole_sup.png" width="250"/></a> <?php endif; ?> </p> </div> <?php endwhile; else: ?> <p>Sorry, no posts matched your criteria.</p> <?php endif; ?> </div> </section> <?php get_sidebar(); ?> <?php get_footer(); ?>
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414259", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Elementor is not showing options to modify OceanWP one of the default theme footer Please refer to below attachment * *I want to modify footer *Want to remove "Free your mind..." but elementor plugin is not showing any option to do so. This is one of the free theme website provider by Ocean WP
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414261", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Images thumbnail not cropping square I'm trying to create a related post file with squares images. In the functions.php I've added the following code: function my_theme_setup() { add_theme_support('post-thumbnails'); // Add Image Sizes add_image_size( 'related-posts', 200, 200, true ); } add_action( 'after_setup_theme', 'my_theme_setup' ); In my related-posts.php, I've added the code: <?php $recent_args = array( 'posts_per_page' => 3, // Number of posts to display 'orderby' => 'date', 'order' => 'DESC', ); $recent_posts = new WP_Query( $recent_args ); if ( $recent_posts ->have_posts() ) { echo '<ul class="list-unstyled d-flex text-center">'; while ( $recent_posts->have_posts() ) { $recent_posts->the_post(); ?> <li class="border col-md-4 d-flex flex-wrap justify-content-center"> <div class="relatedthumb"> <a href="<?php esc_url( the_permalink() )?>" title="<?php the_title(); ?>"> <?php if ( has_post_thumbnail() ) : ?> <a href="<?php esc_url( the_permalink() ); ?>" title="<?php the_title_attribute(); ?>"> <div class="related-post-thumb"> <?php the_post_thumbnail('related-posts'); ?> </div> </a> <?php endif; ?> </a> </div> <div class="relatedcontent"> <h3> <a href="<?php the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a> </h3> </div> </li> <?php } echo '</ul>'; /* Restore original Post Data */ wp_reset_postdata(); } ?> For example, I have an original image: 1600 x 1067 pixels. But the hard cropping is not working. The image has the size 200 x 133 px but not 200 x 200 as I expected. To check if the problem is my code I've tried different things like: <?php the_post_thumbnail('thumbnail'); ?> But I got a 150x100px image size. <?php the_post_thumbnail('medium'); ?> But I got a 300x200px image size. I also tried to regerate thumbnails via plugins, but nothing works. The /wp-admin > Settings > Media method seems to have no effect on my thumbnails. I am not sure what I am doing wrong. A: I found the solution. The problem was not in my code, but in the xampp! The GD extension was missing
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414262", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: wordpress multisite with already existing subdomain I have activated the wordpress multisite in my main domain. Now I want to add an already existing subdomain with a separate wp installation. How can I do it?
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414263", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: How to change permalink structure off default posts and also CPT's posts For example, I need "name of post type / name of post" when I am on single post page and when I am on category page it must look "name of post type / category / category name"
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414264", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Block non logged in users from accessing the media library I have a custom login page for a site I'm working on that isn't related to the backend login. The purpose of this is so users that aren't logged in cannot see the site. When the site loads it looks for a session and if non exists, it redirects the user to the login page and that's all they can see. This all works great, but is there an easy way to also disable non logged in users from accessing the Media Library? Any tips would be appreciated. Thank you.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414266", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Current Page Not Showing in Yoast Breadcrumb My Yoast SEO Premium Plugin does not show the pagination (current page number) on pages; it works perfectly fine on categories. For example, 'Home > Blog > Page 2' is not showing. The blog is a custom page template. It only shows 'Home > Blog' even if you are on page 5. How can I fix this? I couldn't find anything on the internet. Kind regards.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414268", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Yoast SEO is Showing The Current Page in English on The SEO Title My website is in Turkish, and my Yoast SEO Premium Plugin is also in Turkish. But when I use pagination, for example, I go to page 2 on my Blog; in the title section, it says '| Page 2' even though the website is in Turkish. How can I fix this? (LocoTranslate Plugin says it's in Turkish as well). Kind regards.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414270", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Wordpress Query - Blog Cards Duplicate issue My Blog Cards are duplicating every three cards. How can I solve this? <div class="blog-container-ehukuk"> <?php $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $args = array( 'post_type'=> 'post', 'post_status' => 'publish', 'posts_per_page' => 10, 'order' => 'DESC', 'orderby' => 'date', 'paged' => $paged ); $result = new WP_Query( $args ); ?> <?php if ( $result-> have_posts() ) : while ( $result->have_posts() ) : $result->the_post(); ?> <div class="container-fostrap"> <div class="content"> <div class="container"> <div class="row"> <div class="col-xs-12 col-sm-4"> <div class="card"> <img src="<?php the_post_thumbnail_url('full'); ?>" alt="card__image" class="card__image" width="100%"> <div class="card-content"> <h4 class="card-title"> <a href="http://www.fostrap.com/2016/03/bootstrap-3-carousel-fade-effect.html"> Bootstrap 3 Carousel FadeIn Out Effect </a> </h4> <p class=""> Tutorial to make a carousel bootstrap by adding more wonderful effect fadein ... </p> </div> <div class="card-read-more"> <a href="http://www.fostrap.com/2016/03/bootstrap-3-carousel-fade-effect.html" class="btn btn-link btn-block"> Read More </a> </div> </div> </div> <div class="col-xs-12 col-sm-4"> <div class="card"> <img src="<?php the_post_thumbnail_url('full'); ?>" alt="card__image" class="card__image" width="100%"> <div class="card-content"> <h4 class="card-title"> <a href="http://www.fostrap.com/2016/02/awesome-material-design-responsive-menu.html"> Material Design Responsive Menu </a> </h4> <p class=""> Material Design is a visual programming language made by Google. Language programming... </p> </div> <div class="card-read-more"> <a href="https://codepen.io/wisnust10/full/ZWERZK/" class="btn btn-link btn-block"> Read More </a> </div> </div> </div> <div class="col-xs-12 col-sm-4"> <div class="card"> <img src="<?php the_post_thumbnail_url('full'); ?>" alt="card__image" class="card__image" width="100%"> <div class="card-content"> <h4 class="card-title"> <a href="http://www.fostrap.com/2016/03/5-button-hover-animation-effects-css3.html">5 Button Hover Animation Effects </a> </h4> <p class=""> tutorials button hover animation, although very much a hover button is very beauti... </p> </div> <div class="card-read-more"> <a href="http://www.fostrap.com/2016/03/5-button-hover-animation-effects-css3.html" class="btn btn-link btn-block"> Read More </a> </div> </div> </div> </div> </div> </div> </div> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <?php endif; ?> </div> A: In comments Tom J Nowell already identified + solved the issue Bellow I put code of it, and put functions that call post title, excerpt , permalink instead of static data given in question <div class="blog-container-ehukuk"> <?php $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $args = array( 'post_type'=> 'post', 'post_status' => 'publish', 'posts_per_page' => 10, 'order' => 'DESC', 'orderby' => 'date', 'paged' => $paged ); $result = new WP_Query( $args ); ?> <?php if ( $result-> have_posts() ) { ?> <!-- Wrapper Divs --> <!-- One time --> <div class="container-fostrap"> <div class="content"> <div class="container"> <div class="row"> <?php while ( $result->have_posts() ) { $result->the_post(); ?> <!-- Repeater Div that has post data in it--> <!-- Multiple times --> <div class="col-xs-12 col-sm-4"> <div class="card"> <img src="<?php the_post_thumbnail_url('full'); ?>" alt="card__image" class="card__image" width="100%"> <div class="card-content"> <h4 class="card-title"> <a href="<?php echo get_the_permalink();?>"> <?php echo get_the_title();?> </a> </h4> <p class=""> <?php echo get_the_excerpt();?> </p> </div> <div class="card-read-more"> <a href="<?php echo get_the_permalink();?>" class="btn btn-link btn-block"> Read More </a> </div> </div> </div> <!-- Repeater Div END --> <?php } ?> </div> </div> </div> </div> <!-- Wrapper Divs END --> <?php } wp_reset_postdata(); wp_reset_query(); ?> </div>
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414271", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: How to link and display an "example.php"? I have created an example.php: <?php get_header(); get_template_part('template-parts/banner','title'); ?> <div class="container"> <p>HERE GOES THE TEXT</p> </div> <?php get_footer(); ?> in the page-main.php I have created a link: <a href="<?php echo site_url('/example.php'); ?></a> When I click it I can see in (page.php/example-php) the header, the footer but NOT the html part. What am I doing wrong? Please help and thank You for Your help. After searching the net and reading, I figured that inserting this code: <?php while ( have_posts() ) : the_post(); ?> <?php the_content(); ?> <?php endwhile; ?> made my day. Now I can display my page as a new separate page. So now all the code looks like this: <?php get_header(); get_template_part('template-parts/banner','title'); ?> <?php while ( have_posts() ) : the_post(); ?> <?php the_content(); ?> <?php endwhile; ?> <div class="container"> <p>HERE GOES THE TEXT</p> </div> <?php get_footer(); ?> But if You think that its wrong what I have done please let me know. I am learning so please forgive me for my lack of knowledge. A: Those are template files, you're not meant to access/visit/link to them directly, it's posts and pages that have URLs not PHP files. Have a look at page templates, you'd be better creating a page, giving it a page template and linking to that page, not the PHP file. A: To expand on Tom's answer, you need to understand how templates are used by WordPress. They are the framework that 'builds' the page output. You use a template by creating a page, then selecting that template. Start here to learn about templates https://codex.wordpress.org/Templates Note that you should only create templates in your Child Theme. If you put it in an active (non-Child) theme, a theme update will remove your template. Always use Child Themes. There are many plugins that will quickly create a Child Theme, or you can learn about it here: https://developer.wordpress.org/themes/advanced-topics/child-themes/
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414274", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Custom Taxonomy in custom REST API search I am building my first theme where I use a custom search and I would like to include the ability to search by custom taxonomy. Currently, the taxonomy term shows up in Postman but no posts with that taxonomy appear in the search results. "albums": [ { "albumTitle": "Aerobic Dance", "albumImage": "<img src=\"https://vebajefo.local/wp-content/uploads/2022/12/BLOOM001_AerobicDance_Cover-400x400.jpg\" />", "catalog_id": "BLOOM001 Aerobic Dance", "permalink": "https://vebajefo.local/albums/bloom001-aerobic-dance/", "postType": "albums", "albumGenres": { "genres": "Genres: <a href=\"https://vebajefo.local/genre/80s-pop/\">80s Pop</a>." } } ], My current setup has a CPT called “albums” and a custom taxonomy called “genres”. This taxonomy is assigned only to “albums”. Every album is assigned with the lowest taxonomy term in the hierarchy. For example: If my genres are Jazz > Bebop > Big Band, the album is checked with only “Big Band”. In my case: Pop > 80s In functions.php, I registered a custom Rest API search: require get_theme_file_path('/inc/search-route.php'); function aftersunsetmusic_custom_rest () { register_rest_field( 'post', 'authorName', 'albumGenres', array( 'get_callback' => function() {return get_the_author() ;} ) ); } add_action('rest_api_init', 'aftersunsetmusic_custom_rest'); In the search-route.php, I defined the search query like this: <?php add_action('rest_api_init', 'aftersunsetmusicRegisterSearch'); function aftersunsetmusicRegisterSearch() { register_rest_route( 'aftersunsetmusic/v1', 'search', array( 'methods' => WP_REST_SERVER::READABLE, 'callback' => 'aftersunsetmusicSearchResults', 'permission_callback' => '__return_true', ) ); } function aftersunsetmusicSearchResults ($data) { $mainQuery = new WP_Query(array( 'post_type' => array('post', 'page', 'albums', 'artists'), 's' => sanitize_text_field($data['term']) )); $results = array( 'blog' => array(), 'albums' => array(), 'artists' => array(), ); while($mainQuery->have_posts()) { $mainQuery->the_post(); if (get_post_type() == 'post') { $description = null; if(has_excerpt()) { $description = get_the_excerpt(); } else { $description = wp_trim_words( get_the_content(),18); } array_push($results ['blog'], array( 'title' => get_the_title(), 'permalink' => get_the_permalink(), 'blogImage' => get_the_post_thumbnail(), 'authorName' => get_the_author(), 'description' => $description, )); } if (get_post_type() == 'albums') { $relatedArtists = get_field('album_artists'); if ($relatedArtists) { foreach($relatedArtists as $artist) { array_push($results['artists'], array( 'artistName' => get_the_title($artist), 'permalink' => get_the_permalink($artist), 'image' => get_the_post_thumbnail_url( $artist, '' ), 'postType' => get_post_type($artist), )); } } $albumtitle = get_field('album_title'); array_push($results ['albums'], array( 'albumTitle' => $albumtitle, 'albumImage' => get_the_post_thumbnail(0,'medium'), 'catalog_id' => get_the_title(), 'permalink' => get_the_permalink(), 'postType' => get_post_type(), 'albumGenres' => get_the_taxonomies( ), )); } if (get_post_type() == 'artists') { array_push($results['artists'], array( 'artistName' => get_the_title(), 'permalink' => get_the_permalink(), 'image' => get_the_post_thumbnail_url( ), 'postType' => get_post_type(), )); } } $results ['artists'] = array_values( array_unique($results['artists'], SORT_REGULAR)); return $results; } I would like to add the ability to search the albums by its exact taxonomy term and its parent taxonomy. For example: If an album is assigned to “Big Band” and the taxonomy hierarchy is Jazz > Bebop > Big Band, this album shall appear when searching for “Jazz”, or “Bebop”, or “Big Band”. How do I achieve that? I have tried to modify the search query by using the pre_get_posts filter but I am not quite sure how and where to include them.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414277", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "1" }
Q: WordPress Page Slug with URL custom template So I want to create a custom template file for my user profile page something like this URL http://localhost/wordpress/user/username. Here you can see I have created a new page in Admin with this permalink user and I have created a new file in my theme directory at theme/user/page-{slug}.php and below is my code for this file. <?php /* Template Name: User Profile */ wp_head(); ?> This is user profile page <?php wp_footer(); ?> I have also selected this template file in admin for this page and below is the screenshot of this newly created page. But when I go to browser and try this URL http://localhost/wordpress/user/company , its giving me "Page Not Found" error. Can someone guide me what I am doing wrong here ? How can I set a template based on this slug company here which has user in the URL. A: Eventually I found out a solution. Below is how I have achieved this. In my functions.php file, I have put below code. add_filter('query_vars', 'add_user_var', 0, 1); function add_user_var($vars){ $vars[] = 'user'; return $vars; } add_rewrite_rule('^user/([^/]+)/?$','index.php?pagename=user&user=$matches[1]','top'); This generally adds a rewrite rule if it finds user in the URL. Now I have added a page template file name called as page-user.php and added below code to grab my query string. $user = get_query_var('user'); echo $user; I have created a page in backend admin with slug user and selected this template for this page. Hope this helps.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414279", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: How to Box items in cart I would love to box my products and have prices calculated based on the box weight and LxBxH. When I add one more of my items to the cart, the USPS rate is multiplied by the number of items in the cart but it will be a lot cheaper if boxed. In summary, I would love to have the shipping calculated by the weight of the box (containing all items in the cart) and the LxBxH of the box itself. The box can contain up to 12 items. Thanks in advance :
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414280", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: How to build a english-other landuage translation/dictionary website on Wordpress? I am trying to build a dictionary type of website like this site: https://dict.hinkhoj.com/hi-meaning-in-hindi.words https://www.shabdkosh.com/dictionary/english-hindi/hi/hi-meaning-in-hindi I wanted to know if there's any plugin or method that can help me with automatically generating translated meaning for a english word, and have it as a static permalink page on a wordpress website.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414281", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "-1" }
Q: Problem with custom WordPress Rest API search route with query parameters I'm building a search component in a ReactJs application sitting on top of a headless WordPress CMS and I've run into a problem which I can't seem to fix. It might be that I'm doing something obviously wrong - I'm new to this aspect of WordPress. I'm trying to query a specific custom post type: "maritimeimagearchive". "maritimeimagearchive" has a number of custom fields attached to it, one of which is "accepted_image_type". "accepted_image_type" has a number of potential values but to keep things simple I've limited it to "print" and "glass-plate" for testing purposes. If I hit the rest api endpoint with the following request, all works fine: http://localhost:10058/wp-json/rmg/v1/search/?s=manchester However, if I hit the rest api endpoint with either http://localhost:10058/wp-json/rmg/v1/search/?accepted_image_type=print or http://localhost:10058/wp-json/rmg/v1/search/?accepted_image_type=glass-plate, the returned dataset contains all posts with an "accepted_image_type" of "print" or "glass-plate". There are other posts with different "accepted_image_type" values which I've left in for a sanity check and it's not returning those (that would be genuinely weird). But I'm stuck as to what I'm doing wrong. I've checked in Local by Flywheel's wordpress database and the data is in there stored as strings (not arrays or serialised). Here's the full code for the custom route - I'm using Postman to test it. Can anyone give me an idea of what I'm doing wrong? The full code for the route is as follows: <?php add_action('rest_api_init', 'maritimeImageRoute'); function maritimeImageRoute () { register_rest_route('rmg/v1','search', array( 'methods' => WP_REST_SERVER::READABLE, 'callback' => 'getMaritimeImages', )); } function getMaritimeImages ( $data ) { $search_query = $data['s']; $args = array( 'post_type' => 'maritimeimagearchive', 's' => $search_query, 'meta_query' => array( array( 'key' => 'accepted_image_type', 'value' => array('print', 'glass-plate'), 'compare' => 'IN', ), ), ); $query = new WP_Query($args); $data = array(); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); // Get the accepted_image_type field value $accepted_image_type = get_field('accepted_image_type'); $data[] = array( 'id' => get_the_ID(), 'slug' => get_post_field('post_name'), 'permalink' => get_the_permalink(), 'title' => get_the_title(), 'content' => get_the_content(), 'thumbnail' => get_the_post_thumbnail(), 'accepted_image_type' => $accepted_image_type, ); } } wp_reset_postdata(); return $data; } ?> Thanks. A: It isn't reading the acceptable image type parameter because there is no code to read it, and the acceptable image types have been hardcoded here: array( 'key' => 'accepted_image_type', 'value' => array('print', 'glass-plate'), 'compare' => 'IN', ), Much like you did here for the search parameter: $search_query = $data['s']; It needs to do the same for the acceptable image type parameter too. Sidenotes: * *Post meta is ultra fast when you already know the post, get_post_meta is blazingly fast for this reason because you have to give it a post ID. But, post meta is awful for searches, and the performance/scaling cost rises dramatically as the size of the post meta table increases. Instead either replace this field with a custom taxonomy, or store it in both so that you can get the performance benefits of replacing it with a tax_query *you can probably replace this endpoint with the default stock endpoints that come with WordPress. The URLs might not be as pretty due to the extra URL parameters but it would eliminate a bunch of code to maintain for free
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414282", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: What are some best Plugins to add animation in your WP Site? There are several WordPress plugins that you can use to add animations to your website. Give me Some of Your Suggestions
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414283", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "-1" }
Q: Content doesn't fit on large size desktops like 2560x1440 so recently I've made my website fully responsible, anyways on resolutions like 2560x1440 the content is fixed in the size of 1920x1080 and doesnt fit to screens that are bigger. How can I make this more responsive? I've figured using full-width on elementor and working width padding, anyways I just want to use the full-width on this screen sizes and let it boxed under. How can I do that in css? I know how to use media query but I don't find a way to make this looking good. Is there a css rule for full-width? Can I let it boxed but fit to screen? Cheers
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414284", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Where can I get a free website domain with or without free hosting for life? I need a domain name as well as free web hosting with the basic customer and longtime access.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414286", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "-2" }
Q: How to enable auto update for embedded plugins I'm working on a plugin that will support my custom theme. I've embedded some commercial plugins like elementor free and pro elements, but I've noticed that I'm unable to let auto update them if needed and also in preview mode elementor will not apply style to buttons like I see on the visual editor of the pages. This is the constructor of my plugin public function __construct() { add_action('wp_enqueue_scripts', [$this, 'load_theme_assets']); add_action('after_setup_theme', [$this, 'extend_theme_support']); add_action('init', [$this, 'setup_my_carousel']); add_action('admin_init', [$this, 'remove_menu_pages']); // require_once __DIR__ . '/elementor/elementor.php'; require_once __DIR__ . '/pro-elements/pro-elements.php'; require_once __DIR__ . '/my-board/my-board.php'; require_once __DIR__ . '/my-seo/my-seo.php'; } I don't think the problem about preview of some elementor free widgets is caused from the way I'm embedding it, but not sure. Is there any way to enable update for the embedded plugins?
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414288", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Where do I build my updated website? Where should I develop my new version of my WordPress site while my current version is live? In a subdomain of the live one? I want to work on the new site where team members can view the newest updates and where it will be easy to replace the old site with the new one once it is done. Thanks! A: It's really up to you. As a developer, I prefer working locally but if you do not develop but only add/remove/update themes and plugins, then a subdomain can be great. This way, you can freely break your website without disturbing anyone. Nowadays, lots of hosts providers are offering to create staging website in one click. Regards A: I tend to use a subdomain, yes. * *example.com (old site - production) *new.example.com (new site - staging) Then when the new site is ready to go live I will just rename the sites in place and re-point DNS. I follow this general procedure: * *create DNS record old.example.com pointing to the old site *add the domain old.example.com in hosting account for old site, and create an SSL cert for it *log into the old site using example.com and update the address to old.example.com in Settings > WordPress Address (URL) and Settings > Site Address (URL) *test that the old site works on old.example.com, and that you can log into the dashboard *update DNS record example.com to point to the new site *add the domain example.com in hosting account for new site, and create an SSL cert for it (this step may not be necessary if both sites are hosted in the same account) *log into the new site using new.example.com and update the address to example.com in Settings > WordPress Address (URL) and Settings > Site Address (URL) *test that the new site works on example.com, and that you can log into the dashboard
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414293", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Styling best practices for single pages/templates What's the best practice for CSS that is specific to one PHP file? For example, let's say I make a page page-456.php that is styled differently from the rest of the site, what's the best practice to style it and keep my HTML/text ratio good? I did have a look and a few solutions came up - enqueuing etc. but I'm not sure if that's designed for use with templates only?
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414297", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: wpdb->prepare creates random string for % character I have a query like this, $query = "... user LIKE '%-guest-%' ..."; And when I implemented wpdb->prepare in my query, % characters replaced by random strings. I found solution to apply prepare to the part of the query which needs sql injection protection( I mean separating query to multiple string and apply prepare to only the parts where I need to inject user entered variables). So my question is why I get random string when I use wpdb->prepare for a query which includes % character? I'm using Wordpress 6.1.1 and non of the those ( How do you properly prepare a %LIKE% SQL statement? ) and those (prepare() not working) solutions worked for me. Wordpress created long random string instead of % character on all queries I tried. I also tried deactivating all plugins and loading a default theme, but I got the same results. When I did echo $wpdb->prepare(" LIKE '%%-guest-%%'" ); echo $wpdb->prepare(" LIKE '%-guest-%'" ); echo $wpdb->prepare("%s", "%-guest-%" ); echo $wpdb->prepare("%%%s", "-guest-%" ); echo $wpdb->prepare("%%%s%%", "-guest-" ); echo $wpdb->prepare("'%%%s%%'", "-guest-" ); echo $wpdb->prepare("%s", "%%-guest-%%" ); I got those outputs in order. String is randomly generated on every page refresh. LIKE '{abaadfbc0a08cdc488b3b5787097ca4c33fd03adf665dfe397675231bcd7d263}-guest-{abaadfbc0a08cdc488b3b5787097ca4c33fd03adf665dfe397675231bcd7d263}' LIKE '{abaadfbc0a08cdc488b3b5787097ca4c33fd03adf665dfe397675231bcd7d263}-guest-{abaadfbc0a08cdc488b3b5787097ca4c33fd03adf665dfe397675231bcd7d263}' '{abaadfbc0a08cdc488b3b5787097ca4c33fd03adf665dfe397675231bcd7d263}-guest-{abaadfbc0a08cdc488b3b5787097ca4c33fd03adf665dfe397675231bcd7d263}' {abaadfbc0a08cdc488b3b5787097ca4c33fd03adf665dfe397675231bcd7d263}-guest-{abaadfbc0a08cdc488b3b5787097ca4c33fd03adf665dfe397675231bcd7d263} {abaadfbc0a08cdc488b3b5787097ca4c33fd03adf665dfe397675231bcd7d263}-guest-{abaadfbc0a08cdc488b3b5787097ca4c33fd03adf665dfe397675231bcd7d263} '{abaadfbc0a08cdc488b3b5787097ca4c33fd03adf665dfe397675231bcd7d263}-guest-{abaadfbc0a08cdc488b3b5787097ca4c33fd03adf665dfe397675231bcd7d263}' {abaadfbc0a08cdc488b3b5787097ca4c33fd03adf665dfe397675231bcd7d263}-guest-{abaadfbc0a08cdc488b3b5787097ca4c33fd03adf665dfe397675231bcd7d263}
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414300", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: How do I add the metadata of my single post page to my post column without changing template or plugin in phlox pro theme? I use Phlox-pro with the business solutions theme.(webhost ionos if thats important too) I am creating a website for my surfshop and i use the post column, wich comes with the theme and also uses the build in phlox plugin "auxin-portfolio" to display my courses. there are severel options of things to display on the post column that are refering to the single post page. e.g. the title, picture and other things. The thing i am missing is the metadate (in my case price and course time) for me its important that this is displayed on the post column already not only in the post single page. My first idea was to just put random buttons or text fields over the column and locate them over the shown posts, but as the template is only editable as a whole not specificly the posts, i cant bind them to the posts, wich results in huge problems regarding different screen sizes (mobile / tablet version) so my only ideas on how to solve the problem are: * *somehow bind the buttons to the post ids inside the post column, that the location is fixed to the posts. Or *use the same method that the post colum uses to get titel picture e.g. to get the metadata objects and display them in the column. I will refer to post-single-page/post-column, but it might also be known as portfolio-single page / portfolio-grid as far as i understood right. just to clarify i think this is kind of the same thing in my situation. sadly i am not fit in coding as this is also my first website and i am pretty new to the whol situation, i tried a lot with chatgpt, but i without fully understanding the code and how everything works the ai cant really help me either... maybe someone here can :) As this is my first ever question in stack overfolw/stackexchange, if my question is not clear or not specified enough or anything wrong please let me know what to change/ how to improve/ how to be more clear. I will put the code of what i think is responsible for the single post page(single-post.php) and for the post column(post-column.php) <?php global $post; $post_vars = auxin_get_post_format_media( $post, array( 'request_from' => 'single', 'image_from_content' => false, 'media_size' => auxin_get_option( 'post_single_image_size', '' ), 'crop' => auxin_is_true( auxin_get_option( 'post_single_image_keep_aspect_ratio', false ) ) ? false : true, ) ); extract( $post_vars ); // Get the alignment of the title in page content if( 'default' === $title_alignment = auxin_get_post_meta( $post, 'page_content_title_alignment', 'default' ) ){ $title_alignment = auxin_get_option( 'post_single_title_alignment' ); } $title_alignment = 'default' === $title_alignment ? '' : 'aux-text-align-' .$title_alignment; if( 'default' === $post_content_style = auxin_get_post_meta( $post, 'post_content_style', 'default' ) ){ $post_content_style = auxin_get_option( 'post_single_content_style' ); } $post_extra_classes = $post_content_style ? 'aux-'. esc_attr( $post_content_style ) .'-context' : ''; // Whether to display post meta info or not if( 'default' === $show_post_meta_info = auxin_get_post_meta( $post, 'aux_post_info_show', true ) ){ $show_post_meta_info = auxin_get_option( 'show_post_single_meta_info' ); } $show_post_meta_info = auxin_is_true( $show_post_meta_info ); // Whether the title bar is enabled or not if ( 'default' === $show_titlebar = auxin_get_post_meta( $post, 'aux_title_bar_show', "default" ) ) { $show_titlebar = auxin_get_option( $post->post_type . '_title_bar_show' ); } // Use H1 for entry title if title bar is disabled $entry_title_tag = auxin_is_true( $show_titlebar ) ? 'h2' : 'h1'; ?> <article <?php post_class( $post_extra_classes ); ?> > <?php if ( $has_attach ) : ?> <div class="entry-media"> <?php echo $the_media; ?> </div> <?php endif; ?> <div class="entry-main"> <header class="entry-header <?php echo esc_attr( $title_alignment ); ?>"> <?php if( 'quote' == $post_format ) { echo '<p class="quote-format-excerpt">'. $excerpt .'</p>'; } printf( '<%s class="entry-title %s">', $entry_title_tag, ( $show_title ? '' : ' aux-visually-hide' ) ); $post_title = !empty( $the_name ) ? esc_html( $the_name ) : get_the_title(); if( ! empty( $the_link ) ){ echo '<cite><a href="'.esc_url( $the_link ).'" title="'.esc_attr( $post_title ).'">'.$post_title.'</a></cite>'; } else { echo $post_title; } if( "link" == $post_format ){ echo '<br/><cite><a href="'.esc_url( $the_link ).'" title="'.esc_attr( $post_title ).'">'.$the_link.'</a></cite>'; } printf( '</%s>', $entry_title_tag ); ?> <div class="entry-format"> <div class="post-format"> </div> </div> </header> <?php if( $show_post_meta_info || is_customize_preview() ){ ?> <div class="entry-info <?php echo esc_attr( $title_alignment ); ?>"> <?php if ( auxin_get_option( 'post_meta_date_show', true ) ) { ?> <div class="entry-date"><time datetime="<?php echo esc_attr( get_the_date( DATE_W3C ) ); ?>" ><?php echo get_the_date(); ?></time></div> <?php } if ( auxin_get_option( 'post_meta_author_show', true ) ) { ?> <div class="entry-author"> <span class="meta-sep"><?php esc_html_e("by", 'phlox-pro'); ?></span> <span class="author vcard"> <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author" title="<?php echo esc_attr( sprintf( __( 'View all posts by %s', 'phlox-pro'), get_the_author() ) ); ?>" > <?php the_author(); ?> </a> </span> </div> <?php } if ( auxin_get_option( 'post_meta_comments_show', true ) ) { ?> <div class="entry-comments"> <span class="meta-sep"><?php esc_html_e("with", 'phlox-pro'); ?></span> <span class="meta-comment"><?php comments_number( __('no comment', 'phlox-pro'), __('one comment', 'phlox-pro'), __('% comments', 'phlox-pro') );?></span> </div> <?php } if ( auxin_get_option( 'post_meta_categories_show', true ) ) { ?> <div class="entry-tax"> <?php // the_category(' '); we can use this template tag, but customizable way is needed! ?> <?php $tax_name = 'category'; if( ( $cat_terms = wp_get_post_terms( $post->ID, $tax_name ) ) && ! is_wp_error( $cat_terms ) ){ foreach( $cat_terms as $term ){ echo '<a href="'. get_term_link( $term->slug, $tax_name ) .'" title="'.esc_attr__("View all posts in ", 'phlox-pro'). esc_attr( $term->name ) .'" rel="category" >'. esc_html( $term->name ) .'</a>'; } } ?> </div> <?php } edit_post_link(__("Edit", 'phlox-pro'), '<div class="entry-edit">', '</div>', null, 'aux-post-edit-link'); if( ( auxin_get_option( 'show_blog_post_like_button', 1 ) && 'top' === auxin_get_option( 'blog_post_like_button_position', 'top' ) ) || is_customize_preview() ){ if( function_exists('wp_ulike') ){ add_filter( 'wp_ulike_add_templates_args', 'auxin_change_like_icon', 1, 1); wp_ulike( 'get', array( 'style' => 'wpulike-heart', 'button_type' => 'image', 'wrapper_class' => 'aux-wpulike aux-wpulike-single' ) ); remove_filter( 'wp_ulike_add_templates_args', 'auxin_change_like_icon', 1 ); } } ?> </div> <?php } ?> <div class="entry-content"> <?php if( 'quote' == $post_format ) { echo $the_attach; } else { the_content( __( 'Continue reading', 'phlox-pro') ); // clear the floated elements at the end of content echo '<div class="clear"></div>'; // create pagination for page content wp_link_pages( array( 'before' => '<div class="page-links"><span>' . esc_html__( 'Pages:', 'phlox-pro') .'</span>', 'after' => '</div>' ) ); } ?> </div> <?php $show_share_links = auxin_get_option( 'show_post_single_tags_section', true ); $the_tags = get_the_tag_list('<span>'. esc_html__("Tags: ", 'phlox-pro'). '</span>', '<i>, </i>', ''); if( $show_share_links ){ ?> <footer class="entry-meta"> <?php $share_icon = auxin_get_option( 'blog_post_share_button_icon', 'auxicon-share' ) ; ?> <?php if( $show_share_links && defined( 'AUXELS' ) ){ ?> <div class="aux-post-share"> <div class="aux-tooltip-socials aux-tooltip-dark aux-socials aux-icon-left aux-medium"> <span class="aux-icon <?php echo esc_attr( $share_icon ); ?>"></span> <span class="aux-text"><?php esc_html_e( 'Share', 'phlox-pro' ); ?></span> </div> </div> <?php } if( $the_tags ){ ?> <div class="entry-tax"> <?php echo $the_tags; ?> </div> <?php } else { ?> <div class="entry-tax"><span><?php esc_html_e("Tags: No tags", 'phlox-pro' ); ?></span></div> <?php } if ( auxin_get_option( 'show_blog_post_share_button', false ) ) { $data_text = ( 'text' === $share_type = auxin_get_option( 'blog_post_share_button_type', 'icon' ) ) ? 'data-text="' . esc_attr__( 'Share', 'phlox-pro' ) . '"' : ''; $icon_class = ( $share_type == 'text' ) ? 'aux-has-text' : 'aux-icon ' . $share_icon; ?> <div class="aux-single-post-share"> <div class="aux-tooltip-socials aux-tooltip-dark aux-socials aux-icon-left aux-medium aux-tooltip-social-no-text" <?php echo $data_text; ?> > <span class="<?php echo esc_attr( $icon_class ); ?>" <?php echo $data_text;?>></span> </div> </div> <?php } if ( auxin_get_option( 'show_blog_post_like_button', 1 ) && 'bottom' === auxin_get_option( 'blog_post_like_button_position', 'top' ) ) { if ( function_exists( 'wp_ulike' ) ) { add_filter( 'wp_ulike_add_templates_args', 'auxin_change_like_icon', 1, 1 ); wp_ulike( 'get', array( 'style' => 'wpulike-heart', 'button_type' => 'image', 'wrapper_class' => 'aux-wpulike aux-wpulike-single' ) ); remove_filter( 'wp_ulike_add_templates_args', 'auxin_change_like_icon', 1 ); } } ?> </footer> <?php } ?> </div> <?php // get related posts if( auxin_is_true( auxin_get_option('show_post_single_next_prev_nav') ) ){ auxin_single_page_navigation( array( 'prev_text' => esc_html__( 'Previous Post', 'phlox-pro' ), 'next_text' => esc_html__( 'Next Post' , 'phlox-pro' ), 'taxonomy' => 'category', 'skin' => esc_attr( auxin_get_option( 'post_single_next_prev_nav_skin' ) ) // minimal, thumb-no-arrow, thumb-arrow, boxed-image )); } if( function_exists( 'rp4wp_children' ) ){ echo '<div class="aux-related-posts-container">' . rp4wp_children( false, false ) . '</div>'; } ?> <?php if( auxin_get_option( 'show_blog_author_section', 1 ) ) { ?> <div class="entry-author-info"> <div class="author-avatar"> <?php echo get_avatar( get_the_author_meta("user_email"), 100 ); ?> </div><!-- #author-avatar --> <div class="author-description"> <dl> <dt> <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author" title="<?php echo esc_attr( sprintf( __( 'View all posts by %s', 'phlox-pro'), get_the_author() ) ); ?>" > <?php the_author(); ?> </a> </dt> <dd> <?php if( get_the_author_meta('skills') ) { ?> <span><?php the_author_meta('skills');?></span> <?php } if( auxin_get_option( 'show_blog_author_section_text' ) && ( get_the_author_meta('user_description') ) ) { ?> <p><?php the_author_meta('user_description');?>.</p> <?php } ?> </dd> </dl> <?php if( auxin_get_option( 'show_blog_author_section_social' ) ) { auxin_the_socials( array( 'css_class' => ' aux-author-socials', 'size' => 'medium', 'direction' => 'horizontal', 'social_list' => array( 'facebook' => get_the_author_meta('facebook'), 'twitter' => get_the_author_meta('twitter'), 'googleplus' => get_the_author_meta('googleplus'), 'flickr' => get_the_author_meta('flickr'), 'dribbble' => get_the_author_meta('dribbble'), 'delicious' => get_the_author_meta('delicious'), 'pinterest' => get_the_author_meta('pinterest'), 'github' => get_the_author_meta('github') ), 'social_list_type' => 'site', 'fill_social_values' => false )); } ?> </div><!-- #author-description --> </div> <!-- #entry-author-info --> <?php } ?> </article> <article <?php post_class( $post_classes ); ?>> <?php if ( $has_attach && $show_media ) { ?> <div class="entry-media"><?php echo $the_media; ?></div> <?php } ?> <div class="entry-main"> <?php $taxonomy_name = ! isset( $taxonomy_name ) ? 'category' : $taxonomy_name; $max_taxonomy_num = empty( $max_taxonomy_num ) ? 3 : $max_taxonomy_num; $cat_terms = wp_get_post_terms( $post->ID, $taxonomy_name ); $featured_color = get_post_meta( $post->ID, 'auxin_featured_color_enabled', true ) ? get_post_meta( $post->ID, 'auxin_featured_color', true ) : auxin_get_option( 'post_single_featured_color' ); ?> <?php ob_start(); ?> <header class="entry-header"> <?php if( auxin_is_true( $display_title ) || 'quote' == $post_format) { if( 'quote' == $post_format ) { echo '<p class="quote-format-excerpt">'. $excerpt .'</p>'; } ?> <h4 class="entry-title"> <a href="<?php echo !empty( $the_link ) ? esc_url( $the_link ) : esc_url( get_permalink() ); ?>"> <?php $the_name = ! empty( $the_name ) ? $the_name : get_the_title(); echo empty( $words_num ) ? $the_name : wp_trim_words( $the_name, $words_num ); ?> </a> </h4> <?php } ?> <div class="entry-format"> <a href="<?php the_permalink(); ?>"> <div class="post-format format-<?php echo esc_attr( $post_format ); ?>"> </div> </a> </div> </header> <?php $entry_header = ob_get_clean(); if ( empty( $post_info_position ) ) { $post_info_position = 'after-title'; } // print entry-header before entry-info if post info position was set to 'before-title' echo 'after-title' == $post_info_position ? $entry_header : ''; if( 'quote' !== $post_format && auxin_is_true( $show_info ) ) { $show_date = ! isset( $show_date ) ? true : $show_date; ?> <?php if ( ! empty( $cat_terms ) && isset( $show_badge ) && auxin_is_true( $show_badge ) ) { ?> <span class="entry-badge aux-featured-color" data-featured-color="<?php echo !empty( $featured_color ) ? esc_html( $featured_color ) : ''; ?>"> <a href="<?php the_permalink(); ?>"><?php echo esc_html( $cat_terms[0]->name ); ?></a> </span> <?php } ?> <div class="entry-info"> <?php if( auxin_is_true( $show_date ) ){ ?> <div class="entry-date"> <a href="<?php the_permalink(); ?>"> <time datetime="<?php echo esc_attr( get_the_date( DATE_W3C ) ); ?>" title="<?php echo esc_attr( get_the_date( DATE_W3C ) ); ?>" ><?php echo get_the_date(); ?></time> </a> </div> <?php } ?> <?php if ( isset( $display_author_header ) && auxin_is_true( $display_author_header ) ) { ?> <span class="entry-meta-sep meta-sep"><?php esc_html_e("by", 'phlox-pro'); ?></span> <span class="author vcard"> <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author" title="<?php echo esc_attr( sprintf( __( 'View all posts by %s', 'phlox-pro'), get_the_author() ) ); ?>" > <?php the_author(); ?> </a> </span> <?php } ?> <?php if ( auxin_is_true( $display_categories ) ) { $tax_class_name = ! auxin_is_true( $show_date ) ? 'aux-no-sep' : ''; ?> <span class="entry-tax <?php echo esc_attr( $tax_class_name ); ?>"> <?php if( $cat_terms ){ foreach( $cat_terms as $index => $term ){ if( $index + 1 > $max_taxonomy_num ){ break; } if ( !is_wp_error( get_term_link( $term->slug, $taxonomy_name ) ) ) { echo '<a href="'. get_term_link( $term->slug, $taxonomy_name ) .'" title="'.esc_attr__("View all posts in ", 'phlox-pro'). esc_attr( $term->name ) .'" rel="category" >'. esc_html( $term->name ) .'</a>'; } } } ?> </span> <?php } ?> <?php edit_post_link(__("Edit", 'phlox-pro'), '<i> | </i>', ''); ?> <?php if( 'video' === $post_format && ( isset( $show_format_icon ) && auxin_is_true( $show_format_icon ) ) ) { ?> <span class="entry-post-format aux-lightbox-video"> <?php $get_video_url = get_post_meta( $post->ID, '_format_video_embed', true ); if( ! empty( $get_video_url ) ){ echo sprintf( '<a href="%s" class="aux-open-video aux-post-format-icon" data-type="video"><i class="auxicon-play-1" aria-hidden="true"></i></a>', $get_video_url); *apperantly i am only allowed to 30k letters so the 2nd code is cut of after line 97 from 285 ofcourse i can provide all the code or other files if neccesary
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414303", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: How can I remove paginated SEO titles from my WordPress site? Does anyone know how to change the text of the SEO title on a paginated page on WordPress? Or remove it entirely? Right now, it's like "Blog | Page 2" I want to translate it to my own language or remove it. PS: WordPress language is already in my own language, but it still displays in English. Thanks. A: I've fixed the problem with this code: <title> <?php global $page, $paged; wp_title('|', true, 'right'); bloginfo('name'); $site_description = get_bloginfo('description', 'display'); if ($site_description && (is_home() || is_front_page())) echo " | $site_description"; if ($paged >= 2 || $page >= 2) echo ' | ' . sprintf(__('Sayfa %s', 'twentyten'), max($paged, $page)); ?> </title>
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414304", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: How to defer block.json scripts? I'm currently using @wordpress/scripts, but it puts scripts in HEAD and doesn't defer them, which often it's a bad bad thing. I was trying to defer them by doing something like: // block.json { "name": "myproject/counters", "title": "Counters", "description": "Blocco counters", "keywords": ["counters", "counter"], "style": [ "file:./counters.css", "counters_style" ], "script": [ "file:./counters.js", "counters_js" ], "align": "full" } and then I would like to add defer prop like this: if(!is_admin()) add_filter( 'script_loader_tag', 'lr_defer_scripts', 10, 3 ); function lr_defer_scripts( $tag, $handle, $src ) { $defer_scripts = array( 'counters_js' ); if(in_array($handle, $defer_scripts)){ return '<script src="' . $src . '" defer type="text/javascript"></script>' . "\n"; } return $tag; } But, turns out that this filter seems not to 'see' the counters_js $handle. It sees all the other scripts I usually use and defer, but not this one. Seems like passing the counters_js handle to block.json, it's not recognized by @wordpress/scripts.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414306", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "2" }
Q: Fatal error Class-wp-hook, again, but not sure what's triggering it We're suddenly getting these errors in some of our page templates: mod_fcgid: stderr: PHP Fatal error: Uncaught TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, function "viewport_meta" not found or invalid function name in /home/domain.com/wp-includes/class-wp-hook.php:308, referer: https://domain.com/en/ The wp-includes is core Wordpress, so I'm not sure what this is about. The other lines around this error log line are all about the referer, which is often the page just before this one.. it could be any page. So I wonder if the class-wp-hook.php is somehow being called in the page template specific to this page. But there's nothing all that special in this page template that's not also in other pages that do work. Only this one gives the dreaded There has been a critical error on this website. Learn more about troubleshooting WordPress. Any pointers?
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414308", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Quicktags: Cannot make a span class Edit: The solution is as follows: Needed to use <span class=\"title\"> instead of <span class="title">. I am trying to adding custom quicktags like this: function wporg_add_quicktag_paragraph() { wp_add_inline_script( 'quicktags', "QTags.addButton( 'title_tag', 'title', '<span class="title">', '</span>', '', '', 1);" ); } add_action( 'admin_enqueue_scripts', 'wporg_add_quicktag_paragraph' ); Using <span class="title"> throws an error. But if I change <span class="title"> to <span>, it works fine. I was able to add <span class="title"> as a quicktag until the Wordpress 6.0 update. My new code is based of this: https://developer.wordpress.org/apis/quicktags/ Thanks in advance
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414309", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Visual Composer based theme, element only showing up when logged in as admin Hi I'm using a visual composer based theme. I have an image slider on a page and it only shows up when logged as an WP admin. Somehow my friend was able to get to show on their phone when they clicked the link I sent them. I've cleared my cache, restarted my computer, removed unnecessary plugins and it's still only showing up when I'm logged in. This is literally the last thing I need to do for my website to be perfect. Does anyone have any idea of how to resolve this? This is the page: https://studioapotroes.com/Portfolio/honeycomb-coffee-table/ There should be an image slider to the left of the text.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414311", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: wp_signon by user's login by their particular role I am using below script to login to users. And redirecting them to their profile page. This is working fine. $user = wp_signon( array( 'user_login' => $_POST['user-name'], 'user_password' => $_POST['password'] ) , false ); if ( is_wp_error($user) ) { echo $user->get_error_message(); } else { # Redirect to account page after successful login. if ( $user->ID ) { wp_set_current_user( $user->ID, $user->name ); wp_set_auth_cookie( $user->ID, true, false ); wp_redirect( home_url('profile') ); } Now what I want from here is to check the role and if its not the same then don't allow them to login. I have tried to research to put condition somewhere in this function wp_signon to check without any luck so far. Can someone guide me please how can I achieve this. Thanks A: /* Add code below wp_set_auth_cookie( $user->ID, true, false ); */ $current_user = wp_get_current_user(); if($current_user->roles[0]=='personal_account'){ wp_redirect(site_url('/profile')); }else if($current_user->roles[0]=='corporate_user'){ wp_redirect(site_url('/corporate-profile')); }
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414313", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Make a column full width in an inner section What I want to achieve is to make a template element of a column and its content. Since I cannot make a global template of a column I have put it into an inner section, and made the inner section the global template. My issue is that the column has a margin within the inner section: I assume there is a setting for making the column fill the entire horizontal space, but cannot find it. Also there seem to be no results for this on google, but I would assume it to be a common feature, so I feel that I have missed a basic setting... Is it possible to make a column fill the entire inner section?
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414314", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Crop custom image size vs actual size I need to use specific image size with add_image_size to true using ACF image field and wp_get_attachment_image From this side, my image is displayed well and resizes well in 175*200. I would like to know, when I right click on the image and "open image in new tab". Is it possible to make the image display at its actual size and not the size modified by my function ? Because I notice in the element inspector that my url picks this image <img width="175px" height="250px" src="https://exemple.com/wp-content/upload/date/img-175x250.jpg"> Here is an example that I would like to have: https://publications-prairial.fr/voix-contemporaines/index.php?id=320 https://publications-prairial.fr/voix-contemporaines/docannexe/image/465/VoCo_03_couv-small500.jpg (modified)
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414316", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Taxonomy entries are spawning copies of existing entries with the new title as the existing ID, since upgrade We recently upgraded a very old WordPress 5.x site to WordPress 6.1.1 and all seemed to go well but then it was reported that some taxonomies were generating new entries randomly. So we have a taxonomy called article_type, which has entries like * *News - taxonomy=article_type & tag_ID=84 & post_type=post *Opinion - taxonomy=article_type & tag_ID=90 & post_type=post Suddenly all these new entries are starting to appear at the top of the list in edit-tags.php page, like this * *431 - taxonomy=article_type & tag_ID=47033 & post_type=post *90 - taxonomy=article_type & tag_ID=47036 & post_type=post So, the title in each new case is the ID of an existing entry. The taxonomy is declared like this in code: /* Article Type */ $labels = array( 'name' => _x( 'Article Type', 'taxonomy general name', 'sage' ), 'singular_name' => _x( 'Article Type', 'taxonomy singular name', 'sage' ), 'search_items' => __( 'Search Article Types', 'sage' ), 'all_items' => __( 'All Article Types', 'sage' ), 'parent_item' => __( 'Parent Article Type', 'sage' ), 'parent_item_colon' => __( 'Parent Article Type:', 'sage' ), 'edit_item' => __( 'Edit Article Type', 'sage' ), 'update_item' => __( 'Update Article Type', 'sage' ), 'add_new_item' => __( 'Add New Article Type', 'sage' ), 'new_item_name' => __( 'New Article Type Name', 'sage' ), 'menu_name' => __( 'Article Types', 'sage' ), ); $args = array( 'hierarchical' => false, 'labels' => $labels, 'public' => true, 'show_admin_column' => true, 'rewrite' => array( 'slug' => __( 'article-type', 'sage' ) ), ); register_taxonomy( 'article_type', array( 'post' ), $args ); I wonder if anyone has any ideas where to begin troubleshooting this? Many thanks! edit: more info So it seems when you edit/add a post and use a new article_type, like this: Then this appears as a new numeric entry at the top of the article_type list. So it seems there's some code that's incorrectly grabbing/updating these and adding this in on a post update! I have no idea where to even begin to look for this! edit: more info I wonder if this has anything to do with it? The only two taxonomies affected: A: I'll answer this myself, though kudos to @jacob-peattie for noticing the selection box was non-standard and a likely culprit. So we had the 'Radio Buttons for Taxonomies' plugin running (up to date) with the affected taxonomy types selected there. When we removed the taxonomies from there, the problem stopped. But we wanted radio buttons here so tried a few things. One thing that did work was this in the end: This was our original arguments for the taxonomy, and this produced duplicates: $args = array( 'hierarchical' => false, 'labels' => $labels, 'public' => true, 'show_admin_column' => true, 'rewrite' => array( 'slug' => __( 'article-type', 'sage' ) ), ); When we add this meta_box_cb line it works as expected and no more duplicates: $args = array( 'hierarchical' => false, 'labels' => $labels, 'public' => true, 'show_admin_column' => true, 'meta_box_cb' => 'post_categories_meta_box', 'rewrite' => array( 'slug' => __( 'article-type', 'sage' ) ), ); It seems a bit crazy, but I tested this several times and at least in our case it is the solution.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414317", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Protect wp-cron from hackers I would like to get help on protecting wp-cron against hackers. Set up: Lightsail Bitnami Apache server, headless Wordpress CMS, frontend is on AWS Amplify. My wp-admin folder is protected with htpasswd, but my wp-cron can be accessed by hackers. If I protect the whole cms from the root, which is possible since the frontend is on Amplify, the wp-cron won't work. Alternatively I added some important cron tasks into crontab, but Wordfence has tons of cron job which I don't feel like I should copied them over to crontab. It's very important for Wordfence to be run in the backround to protect my cms. Is there any solution? Thanks
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414319", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Redirect non-logged in users to a specific page I am trying to find a way to restrict access to two specific pages to logged in users only. Currently we are using the code below to show a non-logged in user a blank screen with the message "You are not allowed to access this page" however rather than showing this we want to redirect them to the login page (https://craftyquiz.com/my-account/) Is there a way to do this? if( !function_exists('tf_restrict_access_without_login') ): add_action( 'template_redirect', 'tf_restrict_access_without_login' ); function tf_restrict_access_without_login(){ /* get current page or post ID */ $page_id = get_queried_object_id(); /* add lists of page or post IDs for restriction */ $behind_login_pages = [ 58875 ]; if( ( !empty($behind_login_pages) && in_array($page_id, $behind_login_pages) ) && !is_user_logged_in() ): wp_redirect( $url ); exit; endif; } endif; A: /* add code in current theme activate in this file functions.php */ add_action( 'template_redirect', function() { if( ( !is_page('login') ) ) { if (!is_user_logged_in() ) { wp_redirect( site_url( '/login' ) ); // Example : login page exit(); } } });
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414323", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: WP_Query post_tilte search in posts table Here is my array which I am trying to get "apple" keyword in post table but it can't work like I want. Please let me know what is wrong with my array? Array ( [paged] => 1 [posts_per_page] => 50 [tax_query] => Array ( [0] => Array ( [taxonomy] => product_type [field] => slug [terms] => Array ( [0] => chipin ) [operator] => NOT IN ) ) [status] => publish [orderby] => date [order] => DESC [meta_query] => Array ( [0] => Array ( [key] => _stock_status [value] => instock ) [1] => Array ( [key] => post_title [value] => apple [compare] => LIKE ) [2] => Array ( [relation] => OR ) ) [title_filter] => apple [title_filter_relation] => OR [post_type] => product ) Here is query SELECT SQL_CALC_FOUND_ROWS bhs_posts.ID FROM bhs_posts INNER JOIN bhs_postmeta ON ( bhs_posts.ID = bhs_postmeta.post_id ) INNER JOIN bhs_postmeta AS mt1 ON ( bhs_posts.ID = mt1.post_id ) WHERE 1=1 AND ( bhs_posts.ID NOT IN ( SELECT object_id FROM bhs_term_relationships WHERE term_taxonomy_id IN (918) ) ) AND ( ( bhs_postmeta.meta_key = '_stock_status' AND bhs_postmeta.meta_value = 'instock' ) AND ( mt1.meta_key = 'post_title' AND mt1.meta_value LIKE '{c914ad731b1921eeb5b858d7b618d23619ec92314bf850d67e343f6599dee9cc}apple{c914ad731b1921eeb5b858d7b618d23619ec92314bf850d67e343f6599dee9cc}' ) ) AND ((bhs_posts.post_type = 'product' AND (bhs_posts.post_status = 'publish'))) GROUP BY bhs_posts.ID ORDER BY bhs_posts.post_date DESC LIMIT 0, 50 Database table: If I can make query like following then get proper result but I don't know how to change array in Wp SELECT SQL_CALC_FOUND_ROWS bhs_posts.ID FROM bhs_posts INNER JOIN bhs_postmeta ON ( bhs_posts.ID = bhs_postmeta.post_id ) INNER JOIN bhs_postmeta AS mt1 ON ( bhs_posts.ID = mt1.post_id ) WHERE 1=1 AND ( bhs_posts.ID NOT IN ( SELECT object_id FROM bhs_term_relationships WHERE term_taxonomy_id IN (918) ) ) AND ( ( bhs_postmeta.meta_key = '_stock_status' AND bhs_postmeta.meta_value = 'instock' ) AND ( bhs_posts.post_title LIKE 'apple%' ) ) AND ((bhs_posts.post_type = 'product' AND (bhs_posts.post_status = 'publish'))) GROUP BY bhs_posts.ID ORDER BY bhs_posts.post_date DESC LIMIT 0, 50 A: You added title inside $args['meta_query'] and that's why your query doesn't work. Checking the documentation (get_posts / WP_Query) you will find the available parameters, among them title and s. $args = array( 's' => 'apple', 'post_type' => 'product' // // other parameters // 'status`, 'orderby', 'meta_query', ... ) $posts = get_posts($args); If you use the title parameter - the exact match of the post title will be checked. bhs_posts.post_title = 'some text' If you use s parameter - (in simplification) the phrase will be splited and searched in the post title, content and excerpt . ((bhs_posts.post_title like '%some%' OR bhs_posts.post_excerpt like '%some%' OR bhs_posts.post_content like '%some%') AND (bhs_posts.post_title like '%text%' OR bhs_posts.post_excerpt like '%text%' OR bhs_posts.post_content like '%text%')) If you want to search only in the title of a post, you will need to use posts_search or posts_where filter to modify the query. add_filter('posts_search', 'se414324_title_search', 100, 2) function se414324_title_search( $search, $wp_query ) { global $wpdb; $qv = &$wp_query->query_vars; if ( !isset($qv['wpse_title_search']) || 0 == strlen($qv['wpse_title_search']) ) return $search; $like = $wpdb->esc_like( $qv['wpse_title_search'] ) . '%'; $search = $wpdb->prepare( " AND {$wpdb->posts}.post_title LIKE %s", $like ); return $search; } To modify only selected queries, and not all performed by WP, we use our own parameter name, here wpse_title_search in $args array. $args = array( 'wpse_title_search' => 'apple', 'post_type' => 'product', // // other parameters // 'status`, 'orderby', 'meta_query', ... ) $myquery = new WP_Query($args); OR // "suppress_filters" is necessary for the filters to be applied $args = array( 'wpse_title_search' => 'apple', 'post_type' => 'product', 'suppress_filters' => false, // // other parameters // 'status`, 'orderby', 'meta_query', ... ) $posts = get_posts($args); A: /* Use simple Query with s parameter */ $args = array( 'post_type' => 'product', 's' => 'apple', 'post_status' => 'publish', 'posts_per_page' => -1, ); $wp_query = new WP_Query($args);
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414324", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Remote database access on another wordpress site's custom post type Firstsite.com secondsite.com both are Wordpress site and firstsite's data I want to fetch on my secondsite's custom post type template. Secondsite.com has it's own database so I want to use both on single site. What should be right approach to achieve this.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414326", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Wordpress Multisite Network Shared Custom Post from Main Site using single-CPT.php Trying to share a Custom Post from main site to a child site on a multisite network. I am 80% there, with the use of switch_blog I am able to query custom posts on my templates on the child site. I DO NOT want to be duplicating posts for this purpose within the newtwork, I am happy for them all to be sitting and edited on master, whereas the child sites will just read the data. I want to have the same urls, with same content (canonical of course) on both master and sister sites for these custom posts. One thing remains for this, the single post template - single-items.php This works fine on the main site where it uses some heavy rewrites to display the single custom post on a url of the type: /something/taxonomy1/taxonomy2/taxonomy3/single-post However, on the child site, as there is no single items in the list (they are all on master) it displays a 404. Is there a way to hook into the single-post.php template loading so as to force the switch_blog before wordpress goes to check whether the single custom post in question exists and throws a 404? The part declaring the custom post is sitting in a plugin which is network activated (I thought this would have given me the same custom post on the child site with shared data from master, however when the child site was deployed the custom posts stayed empty). A: I seem to have solved it with the following code which I cobbled together from other answers after searching last 24hrs. It gave an error until I removed the restore_current_blog at the end of the function. As this should only be used by the singular page for the custom post type, I am hoping, it seems to work ok now. I am able to read and display single-CPT on the child site pulling in complete data. So a CPT living on master: master.com/tax1/tax2/yax3/single-CPT also works on slave: slave.com/tax1/tax2/yax3/single-CPT even though it is not there. add_action('pre_get_posts', 'custom__pre_get_posts'); function custom__pre_get_posts($query){ //Get access to global variables global $blog_id; global $wp_query; //Make sure we're not in admin, only run on the main query and don't run on our primary site if($query->is_admin || !$query->is_main_query() || $blog_id===1){ return; } //Try running the query //$test_obj = $query->get_queried_object(); //If we didn't get a result then the page wasn't found if(in_array($query->get('post_type'), ['###MY-CUSTOM-POST###'])) { //Switch to the main site switch_to_blog(1); //Reset the query using the same args as the original (the previous reset changes $wpdb) //$wp_query = new WP_Query($query->query_vars); //Re-query the object again. We might need to perform more sanity checks here //$test_obj = $query->get_queried_object(); //Switch back to our current site //restore_current_blog(); // }else{ //This is a normal query for a page that exists, we don't need to do anything } }
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414327", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: "CRITICAL Object of class WP_Error could not be converted to string" using templates with twig I'm getting the fatal error "Critical Object of class WP_Error could not be converted to string". The theme is developed with twig and php files, to separate logic from visual. Somehow, in the frontend, there's no error, but I receive everyday this fatal error in the logs. The error is in single-color.php: $term = wp_get_post_terms( $colection->posts[0]->ID ,'look' ); echo'<span property="itemListElement" typeof="ListItem"><a property="item" typeof="WebPage" title="Go to '.$term[0]->name.'"href="'.get_term_link( $term[0]->term_id).'" class="home"><span property="name">'.$term[0]->name.'</span></a><meta property="position" content="3"></span> > '; Is there anyway to deal with this situation, just to avoid the logs? A: wp_get_post_terms() returns a WP_Error on failure. (Are you sure it's $colection and not $collection in that function call?) You can check the return value using is_wp_error() and decide what you're going to output if it is, in fact, a WP_Error. For example: $term = wp_get_post_terms( $colection->posts[0]->ID ,'look' ); if ( is_wp_error( $term ) ) { echo 'Error: ' . $term->get_error_message(); } else { echo '<span property="itemListElement" typeof="ListItem"> <a property="item" typeof="WebPage" title="Go to ' . $term[0]->name . '"href="' . get_term_link( $term[0]->term_id).'" class="home"> <span property="name">'.$term[0]->name.'</span> </a> <meta property="position" content="3"></span> > '; // Lines broken up for readability }
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414328", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Font Awesome Icons as squares I have been trying to migrate my html css and javascript static website to a wordpress dynamic theme. Everything worked fine and looks perfect but for some reason my font awesome icons appear as squares. This is the website https://www.anasdahshan.me if anyone can help me it would be great thank you so much. <!-- Font Awesome Icon --> <link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri(); ?>/css/all.min.css" /> <ul class="social-icons ml-md-n2 justify-content-center justify-content-md-start"> <li class="social-icons-linkedin"><a data-toggle="tooltip" href="https://www.linkedin.com/in/" target="_blank" title="LinkedIn" data-original-title="LinkedIn"><i class="fab fa-linkedin"></i></a></li> <li class="social-icons-github"><a data-toggle="tooltip" href="https://github.com/" target="_blank" title="Github" data-original-title="GitHub"><i class="fab fa-github"></i></a></li> <li class="social-icons-twitter"><a data-toggle="tooltip" href="https://twitter.com/" target="_blank" title="Twitter" data-original-title="Twitter"><i class="fab fa-twitter"></i></a></li> <li class="social-icons-instagram"><a data-toggle="tooltip" href="https://instagram.com/" target="_blank" title="Instagram" data-original-title="Instagram"><i class="fab fa-instagram"></i></a></li> </ul> Solution: Just use the html code given with the font awesome kit without adding any php tags. The html should be: <link rel="stylesheet" href="https://kit.fontawesome.com/xxxxx.css" crossorigin="anonymous"> <script src="https://kit.fontawesome.com/xxxxxxx.js" crossorigin="anonymous"></script> A: Your all.min.css font is loaded onto your site, but can you please check you have a webfonts directory with files such as fa-solid-900.woff and fa-solid-900.svg - At the bottom of the all.min.css file you will see the @font-face declarations and the required paths relative to your CSS file eg src:url(../webfonts/fa-solid-900.eot); The CSS class names and font-family: "Font Awesome 5 Free" look fine otherwise, so I suspect it's just a case of missing the font files (or the path being incorrect) A: You should be using Font Awesome's provided <link> or <script> tag(s) that they give you with your kit. It should look like this: <link rel="stylesheet" href="https://kit.fontawesome.com/xxxxx.css" crossorigin="anonymous"> or if you prefer the JS method: <script src="https://kit.fontawesome.com/xxxxxxx.js" crossorigin="anonymous"></script> Copying and pasting the code from their CSS file to your local one isn't advisable because there are relative links to Font Awesome custom fonts that can't/won't be included in your site's files. (As @Alexander Holsgrove points out)
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414329", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Wordpress template restored by mistake I clicked on reset button of personalization wordpress page. Now my web template is restored by default. How I can restored the template styles?
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414331", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: How to create custom toggle button in tinymce? I know how to create a basic button with no state. I created two buttons that output custom list styles by outputting ul's with a certain class that is styled in the CSS. But now I would like for the buttons to have a state whereby if I click button 1 and then click button 2, button 1 is disabled and button 2 is enabled and if I click on a custom list style item with button 2 state, button 2 becomes active.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414334", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Localising a Block I'm trying to localise my Gutenberg plugin and block, the PHP side is translated but zero luck on the js side. I tried the official guide, few other blog posts, the solutions posted in this post enter link description here and this one enter link description here but nothing. Not even with the simplest block. Maybe I'm missing something... Any idea? Thanks in advance. WordPress version: 6.1.1 , PHP version: 8.0.28 , WP-CLI version: 2.7.1 EDITED as other answers recommendations: Still not working My structure: /my-block/ /build/ - index.js - index.js.map - index.asset.php /src/ - index.js /languages/ - my-block-es_ES.mo - my-block-es_ES.po - my-block-es_ES.pot - my-block-es_ES-1fdf421c05c1140f6d71444ea2b27638.json - block.json - my-block.php - package.json - ... The main PHP my-block.php: <?php /** * Plugin Name: My Block * Requires at least: 6.1 * Requires PHP: 7.0 * Version: 1 * Text Domain: my-block */ function create_block_my_block_block_init() { register_block_type( __DIR__ ); // Load MO files for PHP. load_plugin_textdomain( 'my-block', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); } add_action( 'init', 'create_block_my_block_block_init' ); function script_translations(){ // Load JSON files for JS - this is necessary if using a custom languages path!! wp_set_script_translations( 'my-block-local-edit-script', 'my-block', plugin_dir_path( __FILE__ ) . '/languages' ); } add_action( 'wp_enqueue_script', 'script_translations' ); The block.json { "apiVersion": 2, "title": "Test Gutenberg Block Title", "name": "my-block/local", "category": "layout", "textdomain": "my-block", "icon": "universal-access-alt", "editorScript": "file:build/index.js" } And the src/index.js that compiles into build/index.js /** * WordPress dependencies */ import { registerBlockType } from '@wordpress/blocks'; import { __ } from '@wordpress/i18n'; // Register the block registerBlockType('my-block/local', { title: __('My Block Local', 'my-block'), edit: function () { return <p> {__('Hello world', 'my-block')} (from the editor)</p>; }, save: function () { return <p> {__('Hello world', 'my-block')} (from the frontend) </p>; }, }); A: There are 2 main issues in your code: * *As stated in my answer, the script handle format is <block name with slashes replaced with hypens>-editor-script, so because your block name is my-block/local, then the script handle is my-block-local-editor-script and not my-block-local-edit-script. *The correct action name is wp_enqueue_scripts (note the "s") and not wp_enqueue_script. However, wp_enqueue_scripts would not work because that's for the front-end (non-admin side). For admin use like the post editing screen at wp-admin/post.php, you can use either admin_enqueue_scripts or a hook specific to the block/Gutenberg editor like enqueue_block_editor_assets. *Your JSON translation file should also be using dfbff627e6c248bcb3b61d7d06da9ca9 which is the value of md5( 'build/index.js' ) (no ./). So the file name should instead be my-block-es_ES-dfbff627e6c248bcb3b61d7d06da9ca9.json That value/hash is also what you'd get when you run this via WP-CLI: wp i18n make-json my-block-<locale>.po ./ --no-purge after doing a cd languages in your plugin directory. How to fix the issues 1 and 2: * *Change the wp_set_script_translations() line (it's line 20 in your code) to: wp_set_script_translations( 'my-block-local-editor-script', // script handle 'my-block', // text domain plugin_dir_path( __FILE__ ) . 'languages' // path to your translation files ); Or you can use generate_block_asset_handle() to generate the script handle: $script_handle = generate_block_asset_handle( 'my-block/local', 'editorScript' ); wp_set_script_translations( $script_handle, 'my-block', plugin_dir_path( __FILE__ ) . 'languages' ); *Change the add_action( 'wp_enqueue_script', 'script_translations' ); (line 22 in your code) to: add_action( 'enqueue_block_editor_assets', 'script_translations' ); // These also work: //add_action( 'admin_enqueue_scripts', 'script_translations' ); //add_action( 'init', 'script_translations' ); Note about using init: Calling register_block_type() will automatically and immediately register the block editor script — see register_block_script_handle(), so init can be used to set the script translations as long as it's called after calling register_block_type().
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414336", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "2" }
Q: Wordpress Missing Images I have an image on my site: https://cac.bensplayground.us/wp-content/uploads/2023/01/BTA-10006078_A.jpg But when I go to File Manager and look in the folder, it simply isn't there. HOW is that even possible? Where is the original file? The only file that is there (that I can see) is the thumbnail (BTA-10006078_A-100x100.jpg) but not the original. Now...this site has almost 30,000 images, so reuploading them isn't an option.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414343", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: I can't log into my website , it says "Error: Cookies are blocked due to unexpected output" I have seen others with this same problem but when I google it it resolves it in a lingo I don't understand. I need a simple answer.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414344", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Translate via URL parameter working only in localhost I have a website and the default language is brazilian portuguese ( already using __() ). Then, using POEdit, I created two others languages: English and Chinese, translated all the terms, tested it using a parameter (?l=en_US, for example) and it pulls the correct language. The only problem is that it only works on localhost (xampp), if I upload it to the server, it doesn't pull the translation at all. I've cleared the cache, uploaded with all in one import, uploaded zip, reset permalinks, checked the reference of the translation folder, and nothing seems to work. Does anyone have any idea?
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414346", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: How to find out what is causing redirect of static content? On a Wordpress site I have a password protected directory at the same level as Wordpress containing static content. Wordpress is installed in the root of the site: https://example.com/ - Wordpress site https://example.com/mydir/* - password protected files e.g. https://example.com/mydir/somefile.txt After authenticating, the browser can download most of the files in there but there are some that are causing a 404 response. E.g. https://example.com/mydir/foo.txt - OK https://example.com/mydir/foo.LICENSE.txt - 404 Update 1: If I put the *.LICENSE.txt file in a non password protected dir I get the same result, so it's probably not related to that. Update 2: Installed the Redirection plugin. It logs a 404 for that file, so it evidently is Wordpress related, rather than http server related. Update 3: The 404 response is actually a secondary effect from a 403 reponse where the 404 is actually for the ErrorDocument. Specifying the 403 error document (in .htaccess) unmasks the 403 and the Redirect plugin no longer logs it. Update 4: I have also tried this on a "lean" install of Wordpress that has no plugins, with the file in a non-protected subdir. Same 403 error. How do I debug this? A: The issue was caused by some global cPanel Wordpress configuration, to which I don't have access, that blocks access to "sensitive" files, evidently based on the file name.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414347", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: I can't edit block with ux builder I really need your help. I am using flatsome as theme. I put into homepage so many columns and sections. Everything is fine in the beginning . Howerver , I want to edit some text or replace images , it does not work. This is my homepage with column and section When I go with "UX builder" , it does not show any sections . Please help me to firgure it out
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414348", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Wordpress Rest API curl Error 28 I'm using Oracle Linux Server 8.7 OS, nginx 1.14.1. On the server i have one wordpress website. On the health page of wordpress is error with rest api: REST API Endpoint: https://xxxx.org/wp-json/wp/v2/types/post?context=edit REST API Response: (http_request_failed) cURL error 28: Connection timed out after 10000 milliseconds I have researched, I think that the problem could be in cURL. Version of URL in the health report is 7.61.1, that is old version and should be updated. Version of cURL in the server is 7.74 curl 7.74.0 (x86_64-pc-linux-gnu) libcurl/7.74.0 OpenSSL/1.1.1k-fips zlib/1.2.11 zstd/1.4.4 Release-Date: 2020-12-09 Protocols: dict file ftp ftps gopher http https imap imaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp Features: alt-svc AsynchDNS HTTPS-proxy IPv6 Largefile libz NTLM NTLM_WB SSL TLS-SRP UnixSockets zstd How i can update curl? Please help me!
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414355", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: How to delete posts with incorrect status This is a weird one. By mistake, I created some posts using WP Webhooks + Make where the post_status was incorrectly set to "published" instead of "publish". Now, for some reason that action wasn't rejected, and the posts were somehow created. 4 of them. The funny thing is that they're not visible through the dashboard in any way. You can see it counts them in "All" but you cannot make them appear in there, as I guess they are not being recognized as proper posts. I also tried to make a Webhook call to delete the posts by ID, since I have their ID based on the automation report. But it just says the post doesn't exist, which is weird. Any idea how to find them and how to properly clean them? Thanks!
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414356", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: rewriteRules WP6 I’ve got a custom post type slides which is set up this way function register_slides() { $labels_slides = array( 'name' => __( 'Slides', 'slides' ), 'singular_name' => __( 'Slide', 'slides' ), 'all_items' => __( 'All Slides', 'slides' ), 'add_new_item' => __( 'Add New', 'slides' ), 'edit_item' => __( 'Edit Slide', 'slides' ), 'new_item' => __( 'New Slide', 'slides' ), 'view_item' => __( 'View Slide', 'slides' ), 'search_items' => __( 'Search Slides', 'slides' ), 'not_found' => __( 'No Slides found', 'slides' ), 'not_found_in_trash' => __( 'No Slides found in Trash', 'slides' ), ); $args_slides = array( 'labels' => $labels_slides, 'public' => true, 'menu_icon' => 'dashicons-products', 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'revisions', 'page-attributes', ), 'has_archive' => true, 'hierarchical' => true, 'rewrite' => array( 'slug' => sprintf( '%s/&slides_categories&', __( 'products', 'slides' ) ), 'with_front' => false, ), ); register_post_type( 'slide', $args_slides ); $labels_slides_categories = array( 'name' => __( 'Slide Categories', 'slides' ), ); $args_slides_categories = array( 'labels' => $labels_slides_categories, 'hierarchical' => true, 'rewrite' => array( 'slug' => __( 'products', 'slides' ), 'with_front' => false, 'hierarchical' => true, ), ); register_taxonomy( 'slides_categories', 'slide', $args_slides_categories ); and following rewriteRules function, which worked fines in WP5 but in WP6 not work anymore. I already debugged but WP is not running through. function slide_rewrite_rule( $rules ) { $newRule1 = sprintf( '%s/([^/]+)/(?:(?!\bpage\b).)+/([^/]+)/?$', __( 'products', 'slides' ) ); // matches products (slides) but let WordPress do taxonomy pagination stuff correctly $newRule2 = sprintf( '%s/([^/]+)/([^/]+)/(?:(?!\bpage\b).)+/([^/]+)/?$', __( 'products', 'slides' ) ); $newRules = array(); $newRules[$newRule1] = 'index.php?slide=$matches[2]'; $newRules[$newRule2] = 'index.php?slide=$matches[3]'; $rules->rules = $newRules + $rules->rules; } add_filter( 'generate_rewrite_rules', 'slide_rewrite_rule' ); also tried this add_filter('rewrite_rules_array',……………) The Slug is made of multilevel categories for example https://example.com/products/cat1/subcat2/prodsname/ I would like to end up with the slug https://example.com/products/cat1/subcat2/prodsname/ on my CPT detail page and that is currently no longer possible, but it worked wonderfully in WP5 with the slide_rewrite_rule() function. The CPT registration is correct and the permalink placeholder is correct in the wp-admin: https://example.com/products/&prods_categories&/prodsname/ because the product should not only be reached in one category, even in all categories . The detail page should be reached in all selected categories correctly, for example even this https://example.com/products/cat2/subcat3/prodsname/
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414357", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: iOS and ajaxComplete EDIT: Hmm, it seems to be working now. Maybe some kind of caching issue. Can anyone offer any help? The following code works fine, except on iOS; $( document ).ajaxComplete(function() { $("#mobile-header-nav ul li#shortlist-link").filter(function(){ return $(this).text().trim() === "0"; }).hide(); $("#mobile-header-nav ul li#shortlist-link").filter(function(){ return $(this).text().trim() != "0"; }).show(); }); Any help appreciated.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414358", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Wordpress post objects in one parent post object I'm creating an event page where we can add an event line-up. Such a line-up consists out of different speakers. So I've create two custom post types: * *Line-up *Speaker On my event page you can select the created line-up. A repeater is used to add speakers (speaker post objects) to a specific line-up. On my event page: <?php /* * get the ID of the selected line-up */ $line_up = get_sub_field('line-up'); $line_up_id = $line_up->ID; ?> <?php /* * Looping over the speakers repeater within the selected line-up */ if( have_rows('speakers', $line_up_id) ): while( have_rows('speakers') ) : the_row(); $speaker_obj = get_sub_field('speaker_object'); $speaker_time = get_sub_field('speaker_time'); var_dump($speaker_obj); // there is no output endwhile; endif; ?> But there is no output.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414360", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Cc header in wp_mail() not working for some reason, the Cc email address won't receive the same mail as the recipient. $headers = array( 'Content-Type: text/html; charset=UTF-8', 'Cc: [email protected]', 'From: IFHC <[email protected]>' ); wp_mail( $receiver, $addonList[$addonId]['Description'], $message, $headers );
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414362", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "1" }
Q: Fatal Error: Uncaught ArgumentCountError: Too few arguments to function - on logout of wordpress dashboard I am getting a fatal error when trying to login to the WP dashboard - and on logout after logging in via the host: Fatal error: Uncaught ArgumentCountError: Too few arguments to function Wpsec\captcha\handlers\WPLoginEventHandler::handle_login_hook(), 1 passed in /var/www/wp-includes/class-wp-hook.php on line 308 and exactly 2 expected in /var/www/wp-content/mu-plugins/vendor/wpsec/wp-captcha-plugin/src/handlers/WPLoginEventHandler.php:24 Stack trace: #0 /var/www/wp-includes/class-wp-hook.php(308): Wpsec\captcha\handlers\WPLoginEventHandler->handle_login_hook(NULL) #1 /var/www/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters('', Array) #2 /var/www/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #3 /var/www/wp-content/themes/arya-multipurpose-child/functions.php(34): do_action('wp_login_failed', NULL) #4 /var/www/wp-includes/class-wp-hook.php(308): {closure}(NULL, '', '') #5 /var/www/wp-includes/plugin.php(205): WP_Hook->apply_filters(NULL, Array) #6 /var/www/wp-includes/pluggable.php(614): apply_filters('authenticate', NULL, '', '') #7 /var/www/wp-includes/user.php(95): wp_authenticate('', '') #8 /var/www/wp-login.php in /var/www/wp-content/mu-plugins/vendor/wpsec/wp-captcha-plugin/src/handlers/WPLoginEventHandler.php on line 24 However I have only added code to arya-multipurpose-child/functions.php: //add hook to redirect the user back to the elementor login page if the login failed add_action( 'wp_login_failed', 'elementor_form_login_fail' ); function elementor_form_login_fail( $username ) { $referrer = wp_get_referer(); // where did the post submission come from? // $referrer = array(); // if there's a valid referrer, and it's not the default log-in screen if ( !empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin') ) { //redirect back to the referrer page, appending the login=failed parameter and removing any previous query strings //maybe could be smarter here and parse/rebuild the query strings from the referrer if they are important wp_redirect(preg_replace('/\?.*/', '', $referrer) . '/?login=failed' ); exit; } } add_filter( 'authenticate', function( $user, $username, $password ) { // forcefully capture login failed to forcefully open wp_login_failed action, // so that this event can be captured if ( empty( $username ) || empty( $password ) ) { do_action( 'wp_login_failed', $user ); } return $user; }, 10, 3 ); // to handle even you can handle the error like add_action( 'wp_login_failed', function( $username ) { if ( is_wp_error( $username ) ) { // perform operation on error object for empty error } } ); ?> The additions are working as desired on the login form on the home page when there is ANY kind of failed login i.e. redirecting back to the login page while also returning ?login=failed so as to trigger the "Login failed!" message on the page. However I am struggling to find where I am going wrong with the arguments. Grateful for any help.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414363", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Dynamically add table of contents and add anchor based on heading innerHTML I am looking to do the following:- * *Parse the blocks on a page and check to see if the block is a core/group block *If it is, check the first innerBlocks is a core/heading (would be useful to achieve this and check a classname if possible) *If it is, take the content of that first inner block, strip all of its tags and add the result to the $headings array for later use *Then, modify the markup of that first block, adding an id attribute made up of the innerHTML, stripped of it's tags. Repurposed in the following way str_replace(' ', '-', $innerHTML) *Once that has been done, create the anchor links from the previously saved $headings array, then render the blocks as normal 1,2,3, and 5 I appear to be able to achieve. Number four seems to be where I am coming unstuck. I guess this is because parse_blocks is happening after the markup has been generated, so at this point I cannot make any further alterations. Does anyone have ideas for how I can achieve the fourth item on the list, adding the anchor to the first block in a group? Ideally, I want as little input required in the backend. So the user would add a core/group block, then its content. As long as the first item in that group block is a heading, it will automatically use that as it's anchor name and generate a anchor link for it. The code for the current code is as follows: <main> <section> <?php while ( have_posts() ) : the_post(); ?> <?php if(!$post) { global $post; } if(!$post) { return ''; } $headings = []; $blocks = parse_blocks( $post->post_content ); if(count($blocks) == 1 && $blocks[0]['blockName'] == null) { // Non-gutenberg return; } else { foreach($blocks as $block) { if($block["blockName"] == 'core/group') { // check the first block in the group block is a heading if($block['innerBlocks'][0]['blockName'] == 'core/heading') { /** * Get the first heading's inner html and remove all tags from it, * then add it to the $headings arr for later use * */ $content_without_tags = wp_strip_all_tags( $block['innerBlocks'][0]["innerHTML"] ); $headings[] = ['title' => $content_without_tags]; } } } } if(empty($headings)) { // No headings found in post return ''; } $toc = '<ol>'; foreach($headings as $heading) { $toc .= '<li><a href="#' . str_replace(" ", "-", $heading['title']) . '">' . $heading['title'] . '</a></li>'; } $toc .= '</ol>'; echo $toc; the_content(); ?> <?php endwhile; ?> </section> </main> A: I think you should use filters instead, and here are examples based on your code: (these should be added to your theme functions.php file) * *Filter 1, to be hooked on the render_block_data hook: function my_render_block_data( $parsed_block ) { // Check whether it's a group block. if ( 'core/group' === $parsed_block['blockName'] ) { // Check whether the very first block is a heading block. if ( isset( $parsed_block['innerBlocks'][0] ) && 'core/heading' === $parsed_block['innerBlocks'][0]['blockName'] ) { $block = $parsed_block['innerBlocks'][0]; $content = $block['innerContent'][0]; $id = sanitize_title( $content ); global $toc_headings; $toc_headings = is_array( $toc_headings ) ? $toc_headings : array(); // Add the heading to our global headings array, in the form of // `$toc_headings['<HTML id>'] = '<heading text>'`. But it's up to // you if you want to use another format. $toc_headings[ $id ] = wp_strip_all_tags( $content ); // Add an `id` attribute to the heading tag. $new_content = preg_replace( '/<h(\d)( |>)/', '<h$1 id="toc-' . esc_attr( $id ) . '"$2', $content ); // Alternatively, you can add an anchor, e.g. //$anchor = sprintf( '<a id="toc-%s"></a>', esc_attr( $id ) ); //$new_content = $anchor . $content; // Modify the block's content. $parsed_block['innerBlocks'][0]['innerContent'][0] = $new_content; } } return $parsed_block; } *Filter 2, to be hooked on the the_content hook: function my_add_toc_headings( $content ) { global $toc_headings; if ( is_array( $toc_headings ) ) { $toc = '<ol>'; foreach ( $toc_headings as $id => $text ) { $toc .= sprintf( '<li><a href="#toc-%s">%s</a></li>', esc_attr( $id ), esc_html( $text ) ); } $toc .= '</ol>'; // Add the TOC at the top. $content = "$toc $content"; // Reset the list. $toc_headings = array(); } return $content; } So with that, your while loop would be as simple as: while ( have_posts() ) : the_post(); add_filter( 'render_block_data', 'my_render_block_data' ); add_filter( 'the_content', 'my_add_toc_headings' ); the_content(); remove_filter( 'render_block_data', 'my_render_block_data' ); remove_filter( 'the_content', 'my_add_toc_headings' ); endwhile; Note: I conditionally added the filters (or added them in the above way) so that the TOC stuff is only added for the above the_content() call. So for example, the REST API output would be left untouched. Also, the above snippets were tried & tested working with WordPress v6.1.1 and the Twenty Twenty-Three theme.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414364", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Parse error: syntax error, unexpected 'register_post_type' (T_STRING), expecting ')' <?php /* Plugin Name: Products Plugin URI: https://www.pivolet.com/ Description: This plugin creates a custom post type for products with custom fields and taxonomies. Version: 1.0 Author: saqlain riaz Author URI: https://www.pivolet.com/ License: GPL2 */ // Register Custom Post Type function custom_products_post_type() { $labels = array( 'name' => _x( 'Products', 'Post Type General Name', 'text_domain' ), 'singular_name' => _x( 'Product', 'Post Type Singular Name', 'text_domain' ), 'menu_name' => __( 'Products', 'text_domain' ), 'name_admin_bar' => __( 'Product', 'text_domain' ), 'archives' => __( 'Product Archives', 'text_domain' ), 'attributes' => __( 'Product Attributes', 'text_domain' ), 'parent_item_colon' => __( 'Parent Product:', 'text_domain' ), 'all_items' => __( 'All Products', 'text_domain' ), 'add_new_item' => __( 'Add New Product', 'text_domain' ), 'add_new' => __( 'Add New', 'text_domain' ), 'new_item' => __( 'New Product', 'text_domain' ), 'edit_item' => __( 'Edit Product', 'text_domain' ), 'update_item' => __( 'Update Product', 'text_domain' ), 'view_item' => __( 'View Product', 'text_domain' ), 'view_items' => __( 'View Products', 'text_domain' ), 'search_items' => __( 'Search Product', 'text_domain' ), 'not_found' => __( 'Not found', 'text_domain' ), 'not_found_in_trash' => __( 'Not found in Trash', 'text_domain' ), 'featured_image' => __( 'Featured Image', 'text_domain' ), 'set_featured_image' => __( 'Set featured image', 'text_domain' ), 'remove_featured_image' => __( 'Remove featured image', 'text_domain' ), 'use_featured_image' => __( 'Use as featured image', 'text_domain' ), 'insert_into_item' => __( 'Insert into Product', 'text_domain' ), 'uploaded_to_this_item' => __( 'Uploaded to this Product', 'text_domain' ), 'items_list' => __( 'Products list', 'text_domain' ), 'items_list_navigation' => __( 'Products list navigation', 'text_domain' ), 'filter_items_list' => __( 'Filter Products list', 'text_domain' ),); $args = array( $args = array( 'label' => __( 'Product', 'text_domain' ), 'description' => __( 'Product Description', 'text_domain' ), 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'product' ), 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'menu_position' => 5, 'menu_icon' => 'dashicons-cart', 'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields', 'comments', 'excerpt' ), 'taxonomies' => array( 'product_brand', 'product_category') register_post_type( 'product', $args ); } add_action( 'init', 'create_custom_post_type' ); ?>
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414365", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: How to add arbitrary custom CSS to a Wordpress Block Theme using Site Editor? When using a Block Theme then you can use the Site Editor, accessible via: Wordpress Dashboard > Appearance > Editor. — Introduced in Wordpress 5.9 on 2022-01-25. * *Site Editor > Styles (right side panel) allows you to tweak global Styles (typography, colors, layout) and certain selected attributes of Blocks. And thereby alter the CSS which eventually comes out of the Styles Engine. *But how can I add arbitrary custom CSS to a Wordpress Block Theme? Analog to classical themes with customizer support (introduced in WordPress 3.4 2012-06-13) where you can go to: Dashboard > Appearance > Customize > Additional CSS. A: In WordPress 6.1.1 (released 2022-11) this is not possible in the UI. But good news: In Wordpress 6.2 (to be released somewhen March 2023) this will be possible! Was introduced as an experimental feature in Gutenberg 14.8 from 2022-12 (see video ) It works like this: * *Wordpress Dashboard > Appearance > Editor *Open the Styles panel *In the panel you got a new section "Additional CSS". *There you can paste arbitrary CSS. (and its immediately rendered on the canvas nearby)
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414366", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Pagination only showed when no category is set in wp_query tldr: On my production site only, when I set category_name to any category my pagination does not show up. Once I remove category_name from my wp_query the pagination shows up (for all posts on my site, of course). The code & full problem I have a page and set it to my page template with the following code: <div> <?php $paged = (get_query_var( 'paged' )) ? get_query_var( 'paged' ) : 1; $args = array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 1, 'paged' => $paged, 'category_name' => 'videos', ); $my_query = new WP_Query($args); if ($my_query->have_posts()): while ($my_query->have_posts()): $my_query->the_post(); ?> <article> <?php the_title(); ?> </article> <?php endwhile; endif; ?> <div id="my-pagination"> <?php echo paginate_links( array( 'base' => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ), 'total' => $my_query->max_num_pages, 'current' => max( 1, get_query_var( 'paged' ) ), 'format' => '?paged=%#%', 'show_all' => false, 'type' => 'plain', 'prev_next' => true, 'prev_text' => sprintf( '<i></i> %1$s', __( 'Newer Posts', 'text-domain' ) ), 'next_text' => sprintf( '%1$s <i></i>', __( 'Older Posts', 'text-domain' ) ), 'add_args' => false, 'add_fragment' => '', )); ?> </div> </div> My 1 post shows up as expected (FWIW I have 33 posts in the Videos category), but the pagination does not. If I increase posts_per_page to 30 then I see 30 of my Videos posts but no pagination. I tested this out in my local development environment and it works as expected. Debugging steps Some steps I've taken to debug: * *Exported my production database and imported it locally into a fresh install as well as imported all my files from production to local and I still do not see this issue locally *Downgraded WordPress from 6.1.1 to 6.0.3 *I tried using wp_reset_query and wp_reset_postdata *Tried disabling plugins 1 by 1 *Tested using the Query Loop Gutenberg block. This exhibits the same issue: as soon as I add a category filter the pagination disappears Ask How else can I debug this production only issue? Update Below is the full output of var_dump($my_query): object(WP_Query)#3428 (59) { ["query"]=> array(5) { ["post_type"]=> string(4) "post" ["post_status"]=> string(7) "publish" ["category_name"]=> string(6) "videos" ["posts_per_page"]=> int(1) ["paged"]=> int(1) } ["query_vars"]=> array(65) { ["post_type"]=> string(4) "post" ["post_status"]=> string(7) "publish" ["category_name"]=> string(6) "videos" ["posts_per_page"]=> int(1) ["paged"]=> int(1) ["error"]=> string(0) "" ["m"]=> string(0) "" ["p"]=> int(0) ["post_parent"]=> string(0) "" ["subpost"]=> string(0) "" ["subpost_id"]=> string(0) "" ["attachment"]=> string(0) "" ["attachment_id"]=> int(0) ["name"]=> string(0) "" ["pagename"]=> string(0) "" ["page_id"]=> int(0) ["second"]=> string(0) "" ["minute"]=> string(0) "" ["hour"]=> string(0) "" ["day"]=> int(0) ["monthnum"]=> int(0) ["year"]=> int(0) ["w"]=> int(0) ["tag"]=> string(0) "" ["cat"]=> int(31) ["tag_id"]=> string(0) "" ["author"]=> string(0) "" ["author_name"]=> string(0) "" ["feed"]=> string(0) "" ["tb"]=> string(0) "" ["meta_key"]=> string(0) "" ["meta_value"]=> string(0) "" ["preview"]=> string(0) "" ["s"]=> string(0) "" ["sentence"]=> string(0) "" ["title"]=> string(0) "" ["fields"]=> string(0) "" ["menu_order"]=> string(0) "" ["embed"]=> string(0) "" ["category__in"]=> array(0) { } ["category__not_in"]=> array(0) { } ["category__and"]=> array(0) { } ["post__in"]=> array(0) { } ["post__not_in"]=> array(0) { } ["post_name__in"]=> array(0) { } ["tag__in"]=> array(0) { } ["tag__not_in"]=> array(0) { } ["tag__and"]=> array(0) { } ["tag_slug__in"]=> array(0) { } ["tag_slug__and"]=> array(0) { } ["post_parent__in"]=> array(0) { } ["post_parent__not_in"]=> array(0) { } ["author__in"]=> array(0) { } ["author__not_in"]=> array(0) { } ["ignore_sticky_posts"]=> bool(false) ["suppress_filters"]=> bool(false) ["cache_results"]=> bool(true) ["update_post_term_cache"]=> bool(true) ["update_menu_item_cache"]=> bool(false) ["lazy_load_term_meta"]=> bool(true) ["update_post_meta_cache"]=> bool(true) ["nopaging"]=> bool(false) ["comments_per_page"]=> string(2) "50" ["no_found_rows"]=> bool(false) ["order"]=> string(4) "DESC" } ["tax_query"]=> object(WP_Tax_Query)#3400 (6) { ["queries"]=> array(1) { [0]=> array(5) { ["taxonomy"]=> string(8) "category" ["terms"]=> array(1) { [0]=> string(6) "videos" } ["field"]=> string(4) "slug" ["operator"]=> string(2) "IN" ["include_children"]=> bool(true) } } ["relation"]=> string(3) "AND" ["table_aliases":protected]=> array(1) { [0]=> string(21) "wp_term_relationships" } ["queried_terms"]=> array(1) { ["category"]=> array(2) { ["terms"]=> array(1) { [0]=> string(6) "videos" } ["field"]=> string(4) "slug" } } ["primary_table"]=> string(8) "wp_posts" ["primary_id_column"]=> string(2) "ID" } ["meta_query"]=> object(WP_Meta_Query)#3354 (9) { ["queries"]=> array(0) { } ["relation"]=> NULL ["meta_table"]=> NULL ["meta_id_column"]=> NULL ["primary_table"]=> NULL ["primary_id_column"]=> NULL ["table_aliases":protected]=> array(0) { } ["clauses":protected]=> array(0) { } ["has_or_relation":protected]=> bool(false) } ["date_query"]=> bool(false) ["request"]=> string(380) " SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (31) ) AND wp_posts.post_type = 'post' AND ((wp_posts.post_status = 'publish')) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 1 " ["posts"]=> array(1) { [0]=> object(WP_Post)#5715 (24) { ["ID"]=> int(1732) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2023-03-03 19:30:05" ["post_date_gmt"]=> string(19) "2023-03-04 00:30:05" ["post_content"]=> string(434) "
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414370", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Do I need plugin for crypto donation? I see a lot of free and paid plugins for crypto donation on word press sites. But, do I need one? I could just post my QR codes and hash address of my crypto wallet for that coin and say the transport network i use?
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414371", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Escaping admin_url output being passed to js (esc_js vs esc_url) I am now hardening my first WP plugin. One of my buttons calls a js function which is making a POST against admin-ajax.php. The non-hardened code contains the following: onclick = 'kuba_postMyStuff(<?php echo "\"".admin_url("admin-ajax.php")."\""; ?>)' This (pretty old) ticket suggest that admin_url output needs being escaped. In effect I have ended up with the following: onclick = 'kuba_postMyStuff(<?php echo esc_js("\"".esc_url(admin_url("admin-ajax.php"))."\""); ?>)' Is that a good practice? Is that a most optimal thing one can do in such situation?
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414372", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Plugin translations are not loaded from translate.wordpress.org My plugin has 100% translations for few languages in translate.wordpress.org. I have set the correct text domain, slug, "requires at least version" as per documentation below. https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/#text-domains However, when I switch the language of my site to the translated ones, the plugin strings are not translated. I tried activating and deactivating multiple times but it is invain. I see no language files populated under wp-content/languages folder. Can someone please help understand how/when language files are loaded from translate.wordpress.org and how to debug this issue?
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414376", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: This SQL request call all time and overload my server : SELECT meta_value FROM wp_sitemeta WHERE meta_key = 'wp_installer_network' AND site_id = 1 I have this SQL request who is call every time on my website and take between 1 and 2 secondes to execute so my serveur break down. What is it and how delete it ? SELECT meta_value FROM wp_sitemeta WHERE meta_key = 'wp_installer_network' AND site_id = 1 My site is a multisite multilanguale. Thank you A: What is it It's most likely a part of the WPML. This is based on a quick copy paste of wp_installer_network into the github search box. There's also a small chance this is the Types plugin, but you mentioned you had a multilingual plugin installed. No references to wp_installer_network are found in WordPress itself. and how delete it ? You would need to ask this in a WPML community but the easiest way is to deactivate WPML. If you want to keep WPML but still resolve the problem you will need to ask this in a WPML community as 3rd party plugin questions are offtopic here
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414377", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Using Wordpress API to mass update posts freezes the server Our site has recently been infected and a malware code was added to all the 5300+ posts. I wrote a simple app using Wordpress PCL to update the texts of all posts. But after updating a couple hundreds of them, the server freezes completely and I have to do a hard reset of the VPS. I am not versed in web technologies, so I have no idea how to investigate and solve this.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414378", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Wordpress Multisite Network - Site Administrators Can't Access wp-admin I am fairly experienced in Wordpress, but not with Multisite. On a site I am currently building, which is part of a Multisite network, only super-admins on the entire network are able to access the Dashboard for a specific site. Users assigned as an Administrator on the site are not. I thought this may have had to do with something in the functions.php file, Ultimate Member settings, or Multisite Network settings, but I have run tests, and none seem to be the case? Any thoughts on what could cause this, or where else I should look? Thanks!
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414380", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Best performance for use Custom Field in WP I started building a custom theme and I might need to have around 10 to 20 custom fields for posts and I need to 30 custom fields for theme options and image ads banner, and thinking if this will affect the speed of the site. I will also use these custom fields for WP_Query as meta_key. I have used ACF plugin before, but because I have a lot of advertising banners inside the site page, the loading of the banner images was slower than other default WordPress queries. Do you think using ACF is better or option tree? A: Neither will be faster because the root of the performance problem is the WP table design, not the plugin. The post meta table is optimised for finding values when you already know the post ID/keys, it's not designed for searches, though there are mitigations. Searches/grouping/finding is what the taxonomy tables were created for. Finding all posts that have X category or Y post tag is fast because that's what those tables are designed for, it's why tags/etc aren't stored in post meta. Shopping around for plugins won't have any impact on this because they're still post meta values, no matter what system or framework you used to create them. What To Do If you need to search for posts via a meta value, that means either the field should have been a custom taxonomy, or it needs to be recreated in a taxonomy in such a way that it's easier to search for ( e.g. storing precise values in post meta for display, and bucketed/approximate values in a term ). So I Should Only use Taxonomy Terms and Never Use Post Meta? No!!! Using one thing for everything is what got us into this mess in the first place! Post meta is great for stuff you need to display and store, but it's not good for searching/filtering. WP will even bulk fetch all the meta that belongs to a post to save time and optimise things. It's figuring out which posts that's expensive.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414381", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: CPT Custom post type Tags & Categories not showing for 'Editor' user in editor Using the CPT UI plugin I created the "Member Post" post type and associate the Categories and Tags with it. If I log into an admin account, the categories and tags show up in the post editor. If I log in with an editor account, they do not. Help? Is there a setting I need to set or something?
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414382", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Add Input Form for Select Category Like Tags i have about 200 categories. When I have to publish a post, I select a category one by one. How do I select a category by entering such as adding Tags? A: You can add search to list of categories in post editor with this plugin: https://wordpress.org/plugins/admin-category-search/ This plugin is useful when there are a lot of categories.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414384", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Best way for managing images of ads banners I started building a custom theme and I have a lot of ads banner image on different pages of the site. But my concern is about slowing down the site's loading speed. What is the best way to display photo and link fields on the page? I had previously used ACF plugin via get_field, but these advertising banners were loading slower than other parts of the page. Do you have any other suggestions for managing advertising banners? A: Depends on how you build the pages (or theme parts) that 'grab' the images. And how you get new images on the site. If you load via Add Media, then they will get stored in YY-MM folders (see Media Settings). That's OK; they will be grabbed just nicely from there. If you have a fixed file name for your banner (you manually update the same file, and your template/pages call that specific file), then you might be able just to upload the file. No matter how you do it, make sure that you upload optimized JPG files, for faster loading in the browser.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414385", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: An automated WordPress update has failed to complete - But all udpates fail with code -1 I have a wordpress website on my ubunut machine. I do use autoupdates und auto updates for plugins. After I logged in recently I saw that a couple of plugins didn't update as well as wordpress itself. so when I try to update the Duplicate Page plugin for example I get the following Error. Ok so good, I do enable the debug mode by adding these three lines to my wp-config: define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false ); But even after re-generating the error, I don't get any debug file in my wp folder. I restarted nginx, even the machine itself and played around with the maintenance file, but no luck so far. Any Idea?
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414389", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: My Website’s Main URL redirects me to an Archive Page desperately need your help as I’m completely new to this concept called “WordPress”. When I visit www.mydomainname.com, it automatically pulls a page that shows “Archive” right under my Logo and the Menu on the right hand side. To visit my actual home page, I have to click on “Home” from the menu and only then, my actual home page shows up, but with a /home as a suffix to my domain name. Example: www.mydomainname.com/home This happened when I was building and editing my homepage with Elementor (while getting trained on using Elementor). I would like that when someone types my my domainname.com, that they land on my actual home page without them having to click on the “Home” menu. If someone could please help me with detailed steps as this is the fort time Im using WordPress or even building my website. Thanks so very much in advance! A: 1. Go to Appearance → Customize. 2. Select Homepage Settings. 3. Select A static page. 4. From the drop-down menu under Homepage, choose selected page as the front page for your site. 5. Click Save Changes.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414390", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: After migration index page still redirects to old url Hi, I copied my entire site from myexample.com to myexample.org first by using Duplicator plugin but it didnt go well since it gave me encoding errors so I did it manually but now whenever I try to access the new URL it sends me back to the old one. It happens only with myexample.org or myexample.org/index.php since pages such as myexample.org/posts myexample.org/archive and so on work fine. I tried by changing the database values in home and siteurl but no use. I even deleted the htaccess and still no use. Why is this happening? Thank you.
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414391", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: How to put link on a slideshow gallery? I am having trouble putting a link on a slideshow gallery. Slideshow block's (https://wordpress.com/support/wordpress-editor/blocks/slideshow-block/) menu doesn't have any options to put a link. Seeking a way out, I installed MetaSlider (https://wordpress.org/plugins/ml-slider/) where links can be used. However, MetaSlider uses one URL per image, not one URL per gallery, and that does not match my use case. What is the most painless way of putting a link (one link) on a slideshow gallery?
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414394", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: Adding category to existing post (uploaded file) Brand new here and new to WP, running 6.1.1. I uploaded a file that appears in Media Library. What I want to do is programmatically assign multiple categories to the post after it is uploaded. I have the post ID of the uploaded file and am executing the following code using the Code Snippet plugin as a test in order to assign a single category. When editing the category, the tag_ID is 8 and the URL shows taxonomy=category: function test_category_update() { $post_id = 15937; $uploadCategory = array(8); wp_set_object_terms( $post_id, $uploadCategory,'category'); } But it's not assigning a category to the upload/post. Am I using the right function?
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414395", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }
Q: qty box for each color how can I add qty box for each product variation, like this:
{ "language": "en", "url": "https://wordpress.stackexchange.com/questions/414396", "timestamp": "2023-03-29T00:00:00", "source": "stackexchange", "question_score": "0" }