Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello ViruSudha,
    I have the same issue. Can u pls tell me how do u fix it?
    Thanks.

    Forum: Hacks
    In reply to: Query week filter
    Thread Starter efishop

    (@efishop)

    Hello bcworkz and thank u very much for your time and for your help. It seems that u are a wizard of php since u speak such a strange language ??

    I have used this:

    <?php
    $args = array(
     	'category_name' => 'citat-newsar', //must be slug, not name!
    	'posts_per_page' => 1,
    	'date_query' => array(
    		array(
    			'year' => date('Y'),
    			'week' => date('W'),
    		),
    	),
    	'orderby' => 'rand',
    );
    $my_query = new WP_Query( $args ); ?>
    
    <?php $title =  get_the_title(); //note use of non-echoing versions
    $link_url = get_permalink();
    $link_text = get_post_meta( get_the_ID(), 'citat', true );
    echo "<a title=\"$title\" href=\"$link_url\">$link_text</a>"; ?>

    everything works ok put it works only on category page and on post page from witch that custom fields are. We have some custom fields “citat” and “autor” when we publish a post we select some words that goes in “citat” and an author witch goes in “autor”. Than in website header we randomly display those custom fields.
    Our old function works ok but we need a way to display only custom fields “citat” and “autor” from last week.

    Any sugestion?
    And a pay pal account to make u a small donation? (I hope this is not against wp policy).

    Forum: Hacks
    In reply to: Query week filter
    Thread Starter efishop

    (@efishop)

    Thank you bcworkz,
    I added your code but now I get a “Parse error: syntax error, unexpected ‘<‘ ” error. And I can not identify the issue. Can u help with the entire loop?

    $args = array(
     	'category_name' => 'citat',
    	'posts_per_page' => 1,
    	'date_query' => array(
    		array(
    			'year' => date('Y'),
    			'week' => date('W'),
    		),
    	),
    	'orderby' => 'rand',
    );
    $my_query = new WP_Query( $args );
    
    <?php while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
    <a>" title="<?php the_title(); ?>"><?php echo get_post_meta( get_the_ID(), 'citat', true ); ?></a>
    <div class="autor_citat"><?php echo get_post_meta( get_the_ID(), 'autor', true ); ?></div>
    <?php endwhile;

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)