• Hey,
    I currently have 2 concerns regarding functions.php and the overall custom admin page’s functionality.

    1- Is there any way of creating a function for the custom admin page, that will allow the user to rename file-xx.php to file-99.php once the user writes 99? I was thinking about adding a “text” array to my custom admin page through functions.php, so that the user types a number; however I do not know how I could then use this number and add it to a file’s name.

    2- I also wanted to know if it is possible to add PHP stripslashes as an argument for query_posts. For instance `query_posts(‘cat= stripslashes(get_option(“my_arrayid”));’ ‘);

    Thanks in advance!
    Chris

Viewing 6 replies - 1 through 6 (of 6 total)
  • 1. I’m not certain what you are trying to do. I’ve never built a function that allowed users to rename php files.
    2.

    global $query_string;
    $my_id = stripslashes(get_option("my_arrayid"));
    $args = array(
    	'posts_per_page' => 5,
    	'cat' => $my_id
    );
    $myposts = query_posts($query_string, $args);
    Thread Starter crozer

    (@crozer)

    Hey, thanks a bunch. Can I use the last line ($myposts..) instead of if (have posts()) : while.. ?

    EDIT: It works with that code above the if (have posts()).. snippet.

    Regarding the function to modify a file’s name: My theme has two different types of single.php files; one for posts (single-post.php) and the other for posts within the Portfolio category (single-19.php). For my portfolio to work properly i.e. that all posts inside that category are shown with the single-19.php structure, I need it to have the ID of the category in its name (19).

    I know it is a really old-school method.. any other ideas?
    Thanks again, really.

    if (have posts()) : while.. starts the loop, you have to keep that.

    I didn’t know about the single-{cat_id}.php. You sure that works? single-{post_type}.php is all that is documented in codex.

    https://codex.www.ads-software.com/Template_Hierarchy#Single_Post_display

    Thread Starter crozer

    (@crozer)

    Yep, it indeed works (it is somewhat unpractical though).

    I was having another concern (not very related, but I assume it’s better to post in here than open a new thread): Is there any way of adding a individual reply link to comments?

    I noticed -a bit late- that my comments.php structure is not listing my comments properly, so that the reply link is shown. Have a look: https://www.chrishonn.com/wp/2010/07/clearfront-title-show-off/#comments

    If there is the possibility to add a individual reply-link, instead of having to code up my comments.php again, I would be very thankful!

    if comments.php has wp_list_comments it should display Reply by default. You can change it to something else.

    <?php
    	$args = array(
    	'reply_text' => 'Say Something!'
    	);
    	wp_list_comments($args); ?>

    https://codex.www.ads-software.com/Migrating_Plugins_and_Themes_to_2.7/Enhanced_Comment_Display

    Thread Starter crozer

    (@crozer)

    I understand that, but I am wondering if there’s any other way of showing the reply LINK. (I am not interested in the heading that says ‘Reply’ or something like that)

    Thanks again ??
    Here is my comments.php by the way: https://pastebin.com/qb5FpQmV

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Functions.php doubts/concerns’ is closed to new replies.