Get posts after calculating meta key

Assuming meta_count is another column in your postmeta table below query should get you the posts based on meta_value/meta_count calculation. $postids=$wpdb->get_col( $wpdb->prepare( “SELECT post_id FROM $wpdb->postmeta ORDER BY (meta_value/meta_count) LIMIT 10 ” ) ); The result $postids would be an array. You will have to declare $wpdb as a global variable before you use this … Read more

custom theme’s search not working

See the Codex page for Template Heirarchy – https://codex.wordpress.org/Template_Hierarchy#Search_Result_display Based on the links you provided, I’d guess the error stems from using a “static” index page. If your index.php file doesn’t contain a loop to iterate through posts, it won’t display any search results. You can retain a “static” index if you create a search.php … Read more

Display recent posts on front page

Try this, <?php $args_latest = array( ‘post_type’ => ‘post’, ‘ignore_sticky_posts’ => 1, ‘posts_per_page’ => 4 ); $the_query = new WP_Query($args_latest); ?> <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?> <article> <a href=”https://wordpress.stackexchange.com/questions/155609/<?php the_permalink() ?>”><img src=”https://wordpress.stackexchange.com/questions/155609/<?php bloginfo(“template_directory’); ?>/img/post-images/Adithi_Dinner_blog.jpg” class=”border” alt=”image” /><h1><?php the_title(); ?></h1></a> <p><?php echo substr(strip_tags($post->post_content), 0, 100);?></p> <!– <?php the_content( ‘Read the full … Read more

customize functionality of share buttons under each blog post [closed]

Okay so this will be your jQuery code. <script type=”text/javascript”> $(document).ready(function() { $(‘.thumbup’).on(‘click’, function(){ $(this).parents(‘.entry’).find(“.hidden-like”).toggle(); }); }); </script> But to use it, you will have to change couple of IDs in classes or you can also add classes with IDs. You can not use ID as you wish. The id attribute specifies a unique id … Read more

Add option for administrator to submit link

If you have sucessfully added option field in Theme options; Now you just need to call it on front end. For that just use get_option( $option, $default ); For example if you are saving your social link with key “text_box_value”, then you can simply call it in front end as following; <a href=”https://wordpress.stackexchange.com/questions/189157/<?php echo get_option(“text_box_value’ … Read more

How to create custom page templates with default page layout framework?

I think you are doing this right… but in the wrong direction. What if you separate your default structure like: content-header.php <?php get_header(); get_sidebar(); ?> <div id=”content”> content-footer.php </div> <?php get_footer(); ?> And then you can use get_template_part to put all together: index.php <?php get_template_part( ‘content’, ‘header’ ); ?> <?php while ( have_posts() ) { … Read more