Dynamically display font icons in widget

This is more a PHP question from what I can gather, but hopefully this will help or at least get you on your way. I am making a few assumptions here, like you already have FontAwesome called and working in your site for example. I am also not sure why you have 2x get_post_meta(); functions … Read more

Dynamically replicate custom metabox in custom post type

please try this code. this code will create meta boxes dynamically <?php add_action( ‘add_meta_boxes’, ‘dynamic_add_custom_box’ ); /* Adds a box to the main column on the Post and Page edit screens */ function dynamic_add_custom_box() { add_meta_box( ‘dynamic_sectionid’, __( ‘Shortcode Information’, ‘myplugin_textdomain’ ), ‘dynamic_inner_custom_box’, ‘post’);} Please add slug name of Custom post in above function in … Read more

WordPress pagination not working in search result page

okay sorry for mentioning only link as an answer.. if first pagination link shows 404 error that should be a permalink issue. but to u its second page so definitely it because of some code mistake. please check this code. /*Loop Pagination – A WordPress script for creating paginated links on archive-type pages.*/ function loop_pagination( … Read more

Populate custom field on publish or update

Are you using advanced custom fields, correct? Not sure if ACF will pick up the fields without the $post_id set as the second parameter for get_field, so i changed your code to include the post id. function update_booklink_field( $post_id ) { if ( ‘book’ == $_POST[‘post_type’] ) { $genre = get_field(‘genre’,$post_id); $bookname=get_field(‘book name’,$post_id); $author=get_field(‘author’,$post_id); $booklink=”http://mybooks/”.$genre.”https://wordpress.stackexchange.com/”.$author.”https://wordpress.stackexchange.com/”.$bookname.”.com”; … Read more

mySQL queries are executed twice on wordpress website

The use of wpdb->insert and wp_insert_post both accomplish an SQL Insert, which is why you’re seeing 2 records each time. You must use only one instance of an insert method, and then Pass $my_post to WP_Query CLARIFICATION As Milo points out in his comment wpdb->insert will insert into any table, while wp_insert_post is used to … Read more

WordPress Search

Your search form includes this: <input type=”hidden” name=”post_type” value=”postpage” /> So when your search page loads, the query variable ‘post_type’ is set to load posts of type ‘postpage’. Since posts are of type ‘post’ and pages are of type ‘page’, neither of which are ‘postpage’, you do not get what you expected. Next time, don’t … Read more

Removed jQuery script from header.php , any problems?

Here is the correct way to include jQuery in your theme. Open functions.php in your theme folder and add this to it: // Proper way to enqueue scripts and styles function royal_insert_jquery(){ wp_enqueue_script(‘jquery’, false, array(), false, false); } add_filter(‘wp_enqueue_scripts’,’royal_insert_jquery’,1); This will load the WordPress bundled version of jQuery and will make sure that it is … Read more

Make a page (url) not cacheable [closed]

This has nothing to do with caching, but with form auto-completion. It is happening because the browser is set to store form content. To avoid this, you should generate a random code and add it to the name attribute of your input tags. Then send the random generated number trough another hidden input so you … Read more