Using wordpress function to retrieve data

By default $wpdb->get_results() returns results in the form of an array of objects. If you want an array of associative arrays instead, just do this: $results = $wpdb->get_results( “…”, ARRAY_A ); Obviously I’m not familiar with your project or the code you’re using, and I haven’t tested this, but you’d probably want to do something … Read more

Nav menu from plugin to theme

wp_nav_menu() doesn’t accept a single value for a parameter, it takes an array. Proper format (if you are looking to simply call the menu by ID) would look like this: wp_nav_menu( array( ‘menu’ => $menu_id ) ); I’d recommend checking out the full reference in the codex for more information on the available parameters for … Read more

Controlling image output size ACF repeater [closed]

I always set ACF to return “ID” (not object or URL) – that way ACF doesn’t get involved (& potentionally populate an object with vast amounts of data I don’t need) and I can do as I wish: <?php $landing_slideshows = get_field( ‘landing_slideshow’ ); // var_dump( $landing_slideshows ); foreach( $landing_slideshows as $landing_slideshow ) : ?> … Read more

echo var into wp_query

The “cat” variable need to be an ID of the category. It depends how you configured the ACF field in the backend. Maybe you should print_r($selected_cat) to see what’s inside the variable. it is probably an array with the full information of the category.

custom stripe plugin

Ok, so after 2 days of wasted time, I figured out that since my site was requiring a user login, it was redirecting stripe to the login page. Now that I removed that function, stripe is able to connect to my site.

WP_Query() load selected post

You don’t need a query if you the know the post ID: <?php $post_id = absint( $_POST[‘post_id’] ); if ( ! $post = get_post( $post_id ) ) exit; // Error if ( $post->post_status !== ‘publish’ ) exit; // Might want to prevent script kiddies from accessing private content echo ‘<h4>’ . get_the_title( $post ) . … Read more

Get URL of Featured Image After wp_insert_post()

Well you have the ID as $attach_id so you can use a function such as wp_get_attachment_url() where you can pass $attach_id and get a url returned: $featured_url = wp_get_attachment_url( $attach_id ); Or if you want more information such as width, height, etc. you can use functions like wp_get_attachment_image_src() or wp_get_attachment_metadata().

Change MySQL PDO connection to a WPDB connection

You need to repalce the PDO connection object with WPDB object. And for the kind of query in your example, looks like the best way to do it is with $wpdb->getcol. Something like this (didn’t test): if ( isset( $_GET[‘term’] ) ){ global $wpdb; $term = filter_var( $_GET[‘term’], FILTER_SANITIZE_STRING, FILTER_NULL_ON_FAILURE ); if ( is_null( $term … Read more

JS file is not loading when i put wp_head() and wp_footer

Something more like this… function wpdocs_theme_name_scripts() { wp_enqueue_style( ‘style-name’, get_stylesheet_uri() ); // only enqueue jquery if it is not already enqueued! if (!wp_script_is(‘jquery’,’enqueued’)) { wp_enqueue_script( ‘jquery’, ‘https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js’, array(), true ); } // note: last parameter only needed here if custom.js actually needs jquery wp_enqueue_script( ‘script-name1’, get_stylesheet_directory_uri() . ‘/js/custom.js’, array(‘jquery’) ); // all other scripts clearly … Read more

Azure WordPress site – URLs not showing on move from root to subdirectory

According the post you provided, if you are following the section Moving a Root install to its own directory, it seems will make the wordpress dashboard panel via visiting url like “http://example.com/<sub-folder>/…” and wordpress frontend site via “http://example.com”. If this is your requirement, it seems there are some different steps with my test and which … Read more