Skip to content

Instantly share code, notes, and snippets.

@bilalmalkoc
bilalmalkoc / get_meta_values.php
Created August 4, 2018 13:15 — forked from tybruffy/get_meta_values.php
Get all distinct values of a meta field in Wordpress
function _get_all_meta_values($key) {
global $wpdb;
$result = $wpdb->get_col(
$wpdb->prepare( "
SELECT DISTINCT pm.meta_value FROM {$wpdb->postmeta} pm
LEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id
WHERE pm.meta_key = '%s'
AND p.post_status = 'publish'
ORDER BY pm.meta_value",
$key
$(document).ready(function () {
var winHeight = $(window).height(),
docHeight = $(document).height(),
progressBar = $('.wpuprogress'),
max, value;
max = docHeight - winHeight;
$(document).on('scroll', function(){
value = $(window).scrollTop();
<div class="wpuprogress"></div>
function wpu_scripts() {
wp_enqueue_script( 'wpu-progressBar', get_template_directory_uri() . '/js/progressBar.js', array(), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'wpu_scripts' );
.wpuprogress {
position: fixed; /* Çubuğun sayfada sabit kalması için. */
top: 0; /* Çubuğu sayfanın en üstüne aldık. */
height: 2px; /* Çubuğun kalınlığını artırmak için 2 sayısını değiştirebilirsiniz. */
background-color: #f44336; /* Çubuğun rengi. */
}
// Burada herangi bir değişken olmadığı için tek tırnak kullandık.
echo '<a href="#test">Test</a>';
// Değişken kullanmak istiyorsanız çift tırnak kullanın.
echo "<a href='$link'>Test</a>";
echo '<a href="' . esc_attr( $link ) . '">Test</a>';
// foreach için örnek
foreach( $items as $item ) {
echo $item[ 'title' ];
echo $item[ 'url' ];
echo $item[ 'description' ];
}
// if else için örnek
if( have_posts() ) {
echo 'Yazı Bulundu!';
// Tek ögeli dizi için tek satır kullanılmalı.
$query = new WP_Query( array( 'ID' => 123 ) );
// Birden fazla ögeli dizilerde $args gibi değişkene atanarak
// her bir öge için ayrı satır oluşturulmalı.
$args = array(
'post_type' => 'page',
'post_author' => 123,
'post_status' => 'publish',
);
// Doğru kullanım
$args = array(
'post_type' => 'page',
'post_author' => 123,
'post_status' => 'publish',
);
// Yanlış kullanım
$args = array(
'post_type' => 'page',