New answers tagged

1

This is basically a php question. add_filter( 'facetwp_map_marker_args', function( $args, $post_id ) { $field = get_field( 'Type', $post_id ); // Get this post's ACF value $tent = 'tent'; if( !$field ){ $field = $tent; } $args['icon'] = 'https://www.muddycamper.com/wp-content/themes/oceanwp-child-theme-muddy-camper/images/...


-1

I think you can do something like that, by adding a counter: function link_words($content){ $count = 0; if ( 0 !== $count ) { return; // if count is different from 0, it has already been linked so we return and do nothing. } $words=array('ball'); $links=array( '<a href="https://test.com/tag/ball">ball</a>' ); $content = str_replace(...


0

I haven't tested but something like this should work: function wpse70000_add_author_metabox_to_cpt_book( $args, $post_type ) { if ('product' === $post_type ){ unset($args['editor'] ); // set the 'supports' array } return $args; } add_filter( 'register_post_type_args', 'wpse70000_add_author_metabox_to_cpt_book', 10, 2 );


1

Short Answer I am trying to simply redirect users to a login page if they go to the account page without being logged in. Try with is_page() once again, but use the correct syntax: (see home_url() for more information about the function, but it's an easy way to get your WordPress URL and you can pass any valid path like /login/) add_action( '...


0

I Successfully Solved it and done making The Requirement in easy way 'that's i found for now' i added a js file inside my theme folder with this name "admin.js" i called this file from theme function with this code // replace # with js file link // custom admin menu js add_action( 'admin_enqueue_scripts', 'my_enqueue' ); function my_enqueue() {...


1

The image size dropdown was added in PR #24795 which was included in Gutenberg v9.1 and then included in WordPress 5.6.


0

Please use this <div class="entry-content random-<?php echo time(); ?>"> <style> [class*='random-']{ color:red; font-size:12pt; } </style>


0

One approach is: //... // this is the resulted paragraph without the enclosing <p> and </p> $first_para_inner_text = $matches [1] [1]; // <-- the index changed $link = get_permalink($post); // rebuilding the p $first_para = '<p>' . $first_para_inner_text . ' <a href="'.$link.'">Read More</a></p>'; echo ...


0

Proposed solution does not play nice with WordPress - WordPress default code and filters are ignored. I am giving here much more elegant solution, which keeps all filters like 'nav_menu_submenu_css_class' and other WP default code functioning: <?php /** * Wraps sub-menus in div element */ class My_Menu_Walker extends Walker_Nav_Menu { public ...


0

This is really common when using CLI to run cron jobs (preferred). Wordpress uses PHPMailer and it tries to get SERVER_NAME from $_SERVER variable which is not defined and then it tries few callbacks, resulting in not valid email address. Easiest hacky fix I can think of, define it for example in your wp-config.php if(empty($_SERVER['SERVER_NAME'])) $_SERVER[...


0

From what I see is the issue within your code. Your issue is that you try to fetch the post type in your nested if-statements from the current post, even though at the first if statement, you validate against it and break the function. What you want to do instead is to validate the post type against the $client_id variable. $client_parent = get_post( $...


0

It's not at all about wp_signon , it's does not do redirect It seems that (my_front_end_login_fail) function do . You can simply make sure of this, by commenting this line : // add_action('wp_login_failed', 'my_front_end_login_fail');


2

The problem is that it also shows the featured image, in the same spot, on pages 2, 3, 4, etc of the same article (when I have used <!--nextpage-->). The featured image should only show on the first page of any article. In that case, then this might work for you: function insert_feat_image( $content ) { global $page, $multipage; if ( $...


-1

If you are trying to determine if a singular single.php post page is on a paged() page number then this will require a little more logic. But if you are simply trying execute a function if a post is on an archive page one... then this should be pretty straight forward doing this... <?= // args $args = [ 'post_type' => 'post', 'posts_per_page' => ...


0

You do not have any function to get the html+css+content of a page for the reason the HTML and CSS is provided by the Theme and the content is stored in the DB. About Elementor, I don't know exactly how blocks are stored but CSS is in memory created in a physical file. You can get the content through the_content filter hook https://developer.wordpress.org/...


0

Assuming you are using Yoast SEO plugin - I haven't tested this, but I think you can do something like this: (Source https://pretagteam.com/question/get-primary-category-if-more-than-one-is-selected) /* Checks for a yoast primary category, if it exists move the category to the first position in the $categories array. */ function ...


1

Try this, which uses the parse_request hook: (you can add other conditions, e.g. check whether $wp->query_vars['name'] is not empty, if you want to) add_action( 'parse_request', 'wpse_400900_parse_request', 1 ); function wpse_400900_parse_request( $wp ) { // Redirect if the URL ends with a ? like https://example.com? if ( ! empty( $_SERVER['...


0

I've just tested your code in a function hooked on wp_body_open and it works: add_action( 'wp_body_open', 'function_test' ); function function_test() { $tittle = 'My new page'; $newPage = array( 'post_type' => 'page', 'post_title' => $tittle, 'post_status' => 'publish' ); $post_id = wp_insert_post( $...


0

Your logic is not quite correct as in some cases you will never hit the one return statement. Try this instead: function custom_login_redirect( $redirect_to, $request, $user ) { if ( isset( $user->roles ) && is_array( $user->roles ) ) { if ( in_array( 'administrator', $user->roles ) || in_array( 'editor', $user->roles ) || in_array( ...


Top 50 recent answers are included