• Hi everybody, I really need your support to modify some code of the wordpress theme i am currently using.
    Basically it is a travel blog and in home page i have some featured posts but when user click on “see more” button WP create a page with ALL posts i created. This behaviour is a total mess i would show in this page only some posts that I decide. In the proper .php file that contains the wp-query i find:

    // The Query
    	$args = array(
    		'post_type' => 'destination',
    		'posts_per_page' => 24,
    		'orderby' => array( 'menu_order' => 'ASC', 'parent' => 'ASC', 'title' => 'ASC' ),
    	);
    	$args = is_destination_archive( $args );
    	$the_query = new WP_Query( $args );

    How Do I have to modify the code to show (for instance) just two (or more) specific posts that i consider relevant?

    Let’s say that those two posts have as slug: seychelles and maldive or another that i want to recall with its URL. is it possible?

    Thank a lot to everybody that helps me.

    Bye

Viewing 2 replies - 1 through 2 (of 2 total)
  • Official preliminary to this response:

    The best way to make changes like this to a theme is to use a child theme, so your tweaks won’t be overwritten when updating the theme.

    That said, if you want to show only posts with a certain category or a certain tag, you don’t need to edit the code. You just need to make sure that the “read more” link points to the category or tag archive page. (There are also post format archive pages, if your theme uses post formats, so you could point someone to just galleries or just videos.) You can find this archive page by clicking on the category or tag link in the single post or in the category list or tag cloud widget display. (Typically, such a link will look like http://domain.com/category/category-slug/ or http://domain.com/tag/tag-slug/.

    You can, however, create a custom query and put it into a new template or even your child theme’s functions.php file. For examples of all the different types of queries, see the Codex entry on wp_query.

    Thread Starter ash1982

    (@ash1982)

    Hello,

    I reply to this my old post hoping that i can fix this issue with my website.

    Thanks Sallie for her previous response, i know i could use a child theme but before doing that i would better understand if i am doing right.

    Imagine that i want to recall in this page ONLY some posts based on their slug.

    Is the following code working as expected (look at the first post to see the original code):

    
    // The Query
    $args = array(
    ‘post_type’ => ‘destination’,
    ‘posts_per_page’ => 24,
    ‘orderby’ => array( ‘menu_order’ => ‘ASC’, ‘parent’ => ‘ASC’, ‘title’ => ‘ASC’ ),
    ‘name’ => ‘africa’
    ‘name’ => ‘Europe’
    ‘name’ => ‘Italy’
    ‘name’ => ‘asia’
    ‘name’ => ‘america’
    );
    $args = is_destination_archive( $args );
    $the_query = new WP_Query( $args );
    

    Is that simple?

    Thanks a lot.

    Bye

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WP_Query support needed’ is closed to new replies.