WordPress post insertion from PHP file

The PHP way If you want to use PHP, you can use wp_insert_post to insert posts programatically. Basically you want to provide an array of post information (title, content, date…). You can read more about it here: https://developer.wordpress.org/reference/functions/wp_insert_post/ But the problem is you should not run that function to import all 100 posts. I used … Read more

Different Logo for Different Pages

Try this below code your active theme. $logo = sh_set( $options, ‘site_logo’, get_template_directory_uri().’/images/logo.png’ ); $logo_other = sh_set( $options, ‘site_logo’, get_template_directory_uri().’/images/logo1.png’ ); if (is_page( 42 ) || is_page( 54 ) || is_page( 6 ) || is_page( 8 ) || is_page( 15 ) || is_page( 66 )) { echo ‘<div class=”site-logo”><a href=”‘. esc_url( home_url( “https://wordpress.stackexchange.com/” ) ) … Read more

Same Server, Same PHP, One Site Doesn’t Work [closed]

So, I’ve resolved the issue and I’m not 100% sure what fixed it. However, these are the steps that I took: yum update This resulted in: Found 3 pre-existing rpmdb problem(s), ‘yum check’ output follows: I’m not going to provide the full update, the point is that I couldn’t perform a Yum update because of … Read more

Following/Followers Users list Using Ajax Pagination inside Author Profile

The problem is this line: $curauth = (isset($_GET[‘author_name’])) ? get_user_by(‘slug’, $author_name) : get_userdata(intval($author)); First you make the ajax call with an POST-request, that is the reason why the GET array is empty. Second the variable $author is not defined. So every time you call the script, the variable $curauth is empty. A solution could be … Read more

How to find php variable of wordpress theme settings

Plugin options are normally stored in the wp_options table. If you look at the plugin code (and reference the Plugin information in Codex; you can start here: https://codex.wordpress.org/Writing_a_Plugin ), you will see how the plugin names the option. Then you can create a function that will change that option value. Note that most plugins store … Read more

How can I copy an ACF field to AIOSEO field? [closed]

2 things I noticed: get_field() isn’t specifying a post to get the field from, which is necessary outside the loop: $add_description = get_field( ‘body’, $post->ID );` And to set a post meta value you should use update_post_meta(), not wp_update_post(): update_post_meta( $post->ID, ‘_aioseop_description’, $add_description );

Meta query not showing result properly

You are missing relation argument for inner meta_query arrays as described in the Code Reference. Also, when you use ‘compare’=> ‘IN’, the ‘ship-from’ value should be the array. $args = array( ‘post_type’ => ‘post’, ‘meta_query’ => array( ‘relation’ => ‘AND’, // note this! array( ‘key’ => ‘ship-from’, ‘value’ => ‘usa’, ‘compare’=> ‘IN’ ), array( ‘key’ … Read more

Adding body class to html tag that already has language attrubutes?

Maybe you could use a filter to add the current language of the website to the body class. add_filter(‘body_class’, ‘language_in_body_classes’); function language_in_body_classes($classes) { $classes[] = get_bloginfo(‘language’); return $classes; } Edit : maybe I misunderstood what you wanted. There is actually a language_attributes filter but I do not think it would be very standard to add … Read more