WordPress loop put title into variable

Creating variables on the fly like that is not needed. Just use an array instead. $myvars = []; inside your foreach loop you can: $myvars[] = array(‘title’=>$t,’image’=>$v); After your loop you can: //First title, First image echo $myvars[0][‘title’]; echo $myvars[0][‘image’]; //Second title, Second image echo $myvars[1][‘title’]; echo $myvars[1][‘image’]; This way you can always print_r($myvars) and … Read more

pull 500 post of many from database [duplicate]

function posts_limits_set( $limit, $query ) { if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) { return ‘LIMIT 0, 100’; } return $limit; } add_filter( ‘post_limits’, ‘posts_limits_set’, 10, 2 );

Problem with ms-thumb-frame-selected class in Master Slider

Seems you are simply overwriting #masterslider .ms-thumb-frame-selected with each loop. So in the end only the last iteration will take effect. You maybe need to add the post ID as class somewhere as well and then target #masterslider .ms-thumb-frame-selected .post-<?php echo $post->ID; ?> { } in your CSS. Adjust your markup inside The Loop to … Read more

How to add custom HTML markup and classes to the_content()?

This sounds like something that should be handled in CSS without using classes, for examples article blockquote { background-color: #fff; } Instead of adding .bg-white to the HTML tag. If you really want to add custom classes you could use a filter or get_the_content() and parse it manually.

Custom Page Template and Category Exclusion

Try this code in your template. <?php /** * Template Name: Exclude Comic Category */ get_header(); ?> <div id=”primary”> <div id=”content” role=”main”> <?php query_posts( array( ‘category_name’ => ‘comic’, ‘paged’ => get_query_var(‘paged’), ‘posts_per_page’ => 5 ) ); ?> <?php if ( have_posts() ) : ?> <?php twentyeleven_content_nav( ‘nav-above’ ); ?> <?php while ( have_posts() ) : … Read more

Applying a filter to multiple loops for days ago

Define the filter_where function in your functions.php file in your theme. <?php function filter_where($where=””) { $where .= ” AND post_date > ‘” . date(‘Y-m-d’, strtotime(‘-30 days’)) . “‘”; return $where; }

posts_nav_link() not working on index.php

You are missing the paged= paramter. $myquery = new wp_query(‘cat=-41&paged=’ . get_query_var( ‘page’ )); Codex Note – You should set get_query_var( ‘page’ ) if you want your query to work with pagination. Tip – If you want to eclude a category from main page you can use the pre_get_post filter. That is better way to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)